mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-07 03:22:18 +00:00
de0471aace
* WIP: cmd: separate auth rpc server from regular * WIP: cmd: updates after code review * WIP: cmd: eth and engine should be predefined values for authAPI * cmd: http enabled flag should not affect admin * cmd: eliminate engine checks in case of non-auth * cmd: remove engine from http.api options
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package rpcdaemon
|
|
|
|
import (
|
|
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli/httpcfg"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/ledgerwatch/erigon-lib/common"
|
|
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli"
|
|
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/commands"
|
|
"github.com/ledgerwatch/log/v3"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func RunDaemon() {
|
|
cmd, cfg := cli.RootCommand()
|
|
setupCfg(cfg)
|
|
rootCtx, rootCancel := common.RootContext()
|
|
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
|
ctx := cmd.Context()
|
|
logger := log.New()
|
|
time.Sleep(100 * time.Millisecond)
|
|
db, borDb, backend, txPool, mining, starknet, stateCache, blockReader, ff, err := cli.RemoteServices(ctx, *cfg, logger, rootCancel)
|
|
if err != nil {
|
|
log.Error("Could not connect to DB", "err", err)
|
|
return nil
|
|
}
|
|
defer db.Close()
|
|
if borDb != nil {
|
|
defer borDb.Close()
|
|
}
|
|
|
|
apiList := commands.APIList(db, borDb, backend, txPool, mining, starknet, ff, stateCache, blockReader, *cfg)
|
|
authApiList := commands.AuthAPIList(db, backend, txPool, mining, ff, stateCache, blockReader, *cfg)
|
|
if err := cli.StartRpcServer(ctx, *cfg, apiList, authApiList); err != nil {
|
|
log.Error(err.Error())
|
|
return nil
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
if err := cmd.ExecuteContext(rootCtx); err != nil {
|
|
log.Error(err.Error())
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func setupCfg(cfg *httpcfg.HttpCfg) {
|
|
cfg.WebsocketEnabled = true
|
|
cfg.API = []string{"eth", "erigon", "web3", "net", "debug", "trace", "txpool"}
|
|
}
|