mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-11 05:20:05 +00:00
embed rpcdaemon: enable it only by --http flag (#3574)
This commit is contained in:
parent
fc278327b9
commit
b08cb44353
@ -6,6 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type HttpCfg struct {
|
type HttpCfg struct {
|
||||||
|
Enabled bool
|
||||||
PrivateApiAddr string
|
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.
|
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
|
Datadir string
|
||||||
|
@ -533,27 +533,29 @@ func New(stack *node.Node, config *ethconfig.Config, txpoolCfg txpool2.Config, l
|
|||||||
|
|
||||||
// start HTTP API
|
// start HTTP API
|
||||||
httpRpcCfg := stack.Config().Http
|
httpRpcCfg := stack.Config().Http
|
||||||
ethRpcClient, txPoolRpcClient, miningRpcClient, starkNetRpcClient, stateCache, ff, err := cli.EmbeddedServices(
|
if httpRpcCfg.Enabled {
|
||||||
ctx, chainKv, httpRpcCfg.StateCache, blockReader,
|
ethRpcClient, txPoolRpcClient, miningRpcClient, starkNetRpcClient, stateCache, ff, err := cli.EmbeddedServices(
|
||||||
ethBackendRPC,
|
ctx, chainKv, httpRpcCfg.StateCache, blockReader,
|
||||||
backend.txPool2GrpcServer,
|
ethBackendRPC,
|
||||||
miningRPC,
|
backend.txPool2GrpcServer,
|
||||||
)
|
miningRPC,
|
||||||
if err != nil {
|
)
|
||||||
return nil, err
|
if err != nil {
|
||||||
}
|
return nil, err
|
||||||
|
|
||||||
var borDb kv.RoDB
|
|
||||||
if casted, ok := backend.engine.(*bor.Bor); ok {
|
|
||||||
borDb = casted.DB
|
|
||||||
}
|
|
||||||
apiList := commands.APIList(chainKv, borDb, ethRpcClient, txPoolRpcClient, miningRpcClient, starkNetRpcClient, ff, stateCache, blockReader, httpRpcCfg)
|
|
||||||
go func() {
|
|
||||||
if err := cli.StartRpcServer(ctx, httpRpcCfg, apiList); err != nil {
|
|
||||||
log.Error(err.Error())
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
|
var borDb kv.RoDB
|
||||||
|
if casted, ok := backend.engine.(*bor.Bor); ok {
|
||||||
|
borDb = casted.DB
|
||||||
|
}
|
||||||
|
apiList := commands.APIList(chainKv, borDb, ethRpcClient, txPoolRpcClient, miningRpcClient, starkNetRpcClient, ff, stateCache, blockReader, httpRpcCfg)
|
||||||
|
go func() {
|
||||||
|
if err := cli.StartRpcServer(ctx, httpRpcCfg, apiList); err != nil {
|
||||||
|
log.Error(err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
// Register the backend on the node
|
// Register the backend on the node
|
||||||
stack.RegisterAPIs(backend.APIs())
|
stack.RegisterAPIs(backend.APIs())
|
||||||
|
@ -286,6 +286,7 @@ func ApplyFlagsForNodeConfig(ctx *cli.Context, cfg *node.Config) {
|
|||||||
|
|
||||||
func setEmbeddedRpcDaemon(ctx *cli.Context, cfg *node.Config) {
|
func setEmbeddedRpcDaemon(ctx *cli.Context, cfg *node.Config) {
|
||||||
c := &httpcfg.HttpCfg{
|
c := &httpcfg.HttpCfg{
|
||||||
|
Enabled: ctx.GlobalBool(utils.HTTPEnabledFlag.Name),
|
||||||
Datadir: cfg.DataDir,
|
Datadir: cfg.DataDir,
|
||||||
Chaindata: filepath.Join(cfg.DataDir, "chaindata"),
|
Chaindata: filepath.Join(cfg.DataDir, "chaindata"),
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user