erigon-pulse/cmd/rpcdaemon/main.go

56 lines
1.5 KiB
Go
Raw Normal View History

package main
import (
"fmt"
"os"
"github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli"
"github.com/ledgerwatch/erigon/consensus"
"github.com/ledgerwatch/erigon/consensus/bor"
"github.com/ledgerwatch/erigon/consensus/ethash"
"github.com/ledgerwatch/erigon/rpc"
"github.com/ledgerwatch/erigon/turbo/debug"
"github.com/ledgerwatch/erigon/turbo/jsonrpc"
"github.com/spf13/cobra"
)
func main() {
cmd, cfg := cli.RootCommand()
rootCtx, rootCancel := common.RootContext()
cmd.RunE = func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
2023-07-09 07:04:20 +00:00
logger := debug.SetupCobra(cmd, "sentry")
db, borDb, backend, txPool, mining, stateCache, blockReader, ff, agg, err := cli.RemoteServices(ctx, *cfg, logger, rootCancel)
if err != nil {
logger.Error("Could not connect to DB", "err", err)
return nil
}
defer db.Close()
var engine consensus.EngineReader
if borDb != nil {
defer borDb.Close()
engine = bor.NewRo(borDb, blockReader, logger)
} else {
// TODO: Replace with correct consensus Engine
engine = ethash.NewFaker()
}
apiList := jsonrpc.APIList(db, backend, txPool, mining, ff, stateCache, blockReader, agg, *cfg, engine, logger)
rpc.PreAllocateRPCMetricLabels(apiList)
if err := cli.StartRpcServer(ctx, *cfg, apiList, logger); err != nil {
logger.Error(err.Error())
return nil
}
2022-01-25 16:44:35 +00:00
return nil
}
if err := cmd.ExecuteContext(rootCtx); err != nil {
fmt.Printf("ExecuteContext: %v\n", err)
os.Exit(1)
}
}