diff --git a/cmd/headers/download/sentry.go b/cmd/headers/download/sentry.go index 6b203241b..9545f2d7c 100644 --- a/cmd/headers/download/sentry.go +++ b/cmd/headers/download/sentry.go @@ -36,11 +36,18 @@ import ( "github.com/ledgerwatch/turbo-geth/p2p/nat" "github.com/ledgerwatch/turbo-geth/p2p/netutil" "github.com/ledgerwatch/turbo-geth/params" + "github.com/ledgerwatch/turbo-geth/turbo/node" "google.golang.org/grpc" "google.golang.org/grpc/keepalive" "google.golang.org/protobuf/types/known/emptypb" ) +var ( + // gitCommit is injected through the build flags (see Makefile) + gitCommit string + gitBranch string +) + func nodeKey() *ecdsa.PrivateKey { keyfile := "nodekey" if key, err := crypto.LoadECDSA(keyfile); err == nil { @@ -84,7 +91,9 @@ func makeP2PServer( } p2pConfig.NAT = natif p2pConfig.PrivateKey = serverKey - p2pConfig.Name = "header downloader" + + nodeConfig := node.NewNodeConfig(node.Params{GitCommit: gitCommit, GitBranch: gitBranch}) + p2pConfig.Name = nodeConfig.NodeName() p2pConfig.Logger = log.New() p2pConfig.MaxPeers = 100 p2pConfig.Protocols = []p2p.Protocol{} diff --git a/node/node.go b/node/node.go index b96dbb96d..8829633cc 100644 --- a/node/node.go +++ b/node/node.go @@ -98,7 +98,6 @@ func New(conf *Config) (*Node, error) { server: &p2p.Server{Config: conf.P2P}, databases: make([]ethdb.Closer, 0), } - // Register built-in APIs. node.rpcAPIs = append(node.rpcAPIs, node.apis()...) @@ -113,7 +112,7 @@ func New(conf *Config) (*Node, error) { if err != nil { return nil, err } - node.server.Config.Name = node.config.NodeName() + node.server.Config.Name = node.Config().NodeName() node.server.Config.Logger = node.log if node.server.Config.StaticNodes == nil { node.server.Config.StaticNodes, err = node.config.StaticNodes() diff --git a/turbo/node/node.go b/turbo/node/node.go index ade64f131..1733a0e44 100644 --- a/turbo/node/node.go +++ b/turbo/node/node.go @@ -75,7 +75,11 @@ func New( ) *TurboGethNode { prepareBuckets(optionalParams.CustomBuckets) prepare(ctx) - nodeConfig := makeNodeConfig(ctx, optionalParams) + + nodeConfig := NewNodeConfig(optionalParams) + utils.SetNodeConfig(ctx, nodeConfig) + turbocli.ApplyFlagsForNodeConfig(ctx, nodeConfig) + node := makeConfigNode(nodeConfig) ethConfig := makeEthConfig(ctx, node) @@ -95,7 +99,7 @@ func makeEthConfig(ctx *cli.Context, node *node.Node) *ethconfig.Config { return ethConfig } -func makeNodeConfig(ctx *cli.Context, p Params) *node.Config { +func NewNodeConfig(p Params) *node.Config { nodeConfig := node.DefaultConfig // see simiar changes in `cmd/geth/config.go#defaultNodeConfig` if commit := p.GitCommit; commit != "" { @@ -105,10 +109,6 @@ func makeNodeConfig(ctx *cli.Context, p Params) *node.Config { } nodeConfig.IPCPath = "" // force-disable IPC endpoint nodeConfig.Name = "turbo-geth" - - utils.SetNodeConfig(ctx, &nodeConfig) - turbocli.ApplyFlagsForNodeConfig(ctx, &nodeConfig) - return &nodeConfig }