embed rpcdaemon: enable it only by --http flag (#3574)

This commit is contained in:
Alex Sharov 2022-02-22 16:23:54 +07:00 committed by GitHub
parent fc278327b9
commit b08cb44353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 20 deletions

View File

@ -6,6 +6,7 @@ import (
)
type HttpCfg struct {
Enabled bool
PrivateApiAddr string
SingleNodeMode bool // Erigon's database can be read by separated processes on same machine - in read-only mode - with full support of transactions. It will share same "OS PageCache" with Erigon process.
Datadir string

View File

@ -533,6 +533,7 @@ func New(stack *node.Node, config *ethconfig.Config, txpoolCfg txpool2.Config, l
// start HTTP API
httpRpcCfg := stack.Config().Http
if httpRpcCfg.Enabled {
ethRpcClient, txPoolRpcClient, miningRpcClient, starkNetRpcClient, stateCache, ff, err := cli.EmbeddedServices(
ctx, chainKv, httpRpcCfg.StateCache, blockReader,
ethBackendRPC,
@ -554,6 +555,7 @@ func New(stack *node.Node, config *ethconfig.Config, txpoolCfg txpool2.Config, l
return
}
}()
}
// Register the backend on the node
stack.RegisterAPIs(backend.APIs())

View File

@ -286,6 +286,7 @@ func ApplyFlagsForNodeConfig(ctx *cli.Context, cfg *node.Config) {
func setEmbeddedRpcDaemon(ctx *cli.Context, cfg *node.Config) {
c := &httpcfg.HttpCfg{
Enabled: ctx.GlobalBool(utils.HTTPEnabledFlag.Name),
Datadir: cfg.DataDir,
Chaindata: filepath.Join(cfg.DataDir, "chaindata"),