erigon-pulse/cmd/rpcdaemon/main.go

45 lines
1.2 KiB
Go
Raw Normal View History

package main
import (
"os"
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli"
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/commands"
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/filters"
"github.com/ledgerwatch/erigon/cmd/utils"
2021-07-29 10:23:23 +00:00
"github.com/ledgerwatch/log/v3"
"github.com/spf13/cobra"
)
func main() {
cmd, cfg := cli.RootCommand()
rootCtx, rootCancel := utils.RootContext()
cmd.RunE = func(cmd *cobra.Command, args []string) error {
logger := log.New()
2021-11-14 04:08:52 +00:00
db, backend, txPool, mining, stateCache, blockReader, err := cli.RemoteServices(cmd.Context(), *cfg, logger, rootCancel)
if err != nil {
log.Error("Could not connect to DB", "error", err)
return nil
}
defer db.Close()
var ff *filters.Filters
if backend != nil {
ff = filters.New(rootCtx, backend, txPool, mining)
} else {
log.Info("filters are not supported in chaindata mode")
}
2021-11-14 04:08:52 +00:00
if err := cli.StartRpcServer(cmd.Context(), *cfg, commands.APIList(cmd.Context(), db, backend, txPool, mining, ff, stateCache, blockReader, *cfg, nil)); err != nil {
log.Error(err.Error())
return nil
}
return nil
}
if err := cmd.ExecuteContext(rootCtx); err != nil {
log.Error(err.Error())
os.Exit(1)
}
}