mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
cmd/geth: make ethstats URL settable through config file
This commit is contained in:
parent
0df01af538
commit
03cf680f04
1 changed files with 18 additions and 5 deletions
|
|
@ -79,9 +79,14 @@ var tomlSettings = toml.Config{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ethstatsConfig struct {
|
||||||
|
URL string `toml:",omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type gethConfig struct {
|
type gethConfig struct {
|
||||||
Eth eth.Config
|
Eth eth.Config
|
||||||
Node node.Config
|
Node node.Config
|
||||||
|
Ethstats ethstatsConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadConfig(file string, cfg *gethConfig) error {
|
func loadConfig(file string, cfg *gethConfig) error {
|
||||||
|
|
@ -105,12 +110,14 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
|
||||||
Eth: eth.DefaultConfig,
|
Eth: eth.DefaultConfig,
|
||||||
Node: defaultNodeConfig,
|
Node: defaultNodeConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load config file.
|
// Load config file.
|
||||||
if file := ctx.GlobalString(configFileFlag.Name); file != "" {
|
if file := ctx.GlobalString(configFileFlag.Name); file != "" {
|
||||||
if err := loadConfig(file, &cfg); err != nil {
|
if err := loadConfig(file, &cfg); err != nil {
|
||||||
utils.Fatalf("%v", err)
|
utils.Fatalf("%v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply flags.
|
// Apply flags.
|
||||||
utils.SetNodeConfig(ctx, clientIdentifier, gitCommit, &cfg.Node)
|
utils.SetNodeConfig(ctx, clientIdentifier, gitCommit, &cfg.Node)
|
||||||
stack, err := node.New(&cfg.Node)
|
stack, err := node.New(&cfg.Node)
|
||||||
|
|
@ -118,6 +125,10 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
|
||||||
utils.Fatalf("Failed to create the protocol stack: %v", err)
|
utils.Fatalf("Failed to create the protocol stack: %v", err)
|
||||||
}
|
}
|
||||||
utils.SetEthConfig(ctx, stack, &cfg.Eth)
|
utils.SetEthConfig(ctx, stack, &cfg.Eth)
|
||||||
|
if ctx.GlobalIsSet(utils.EthStatsURLFlag.Name) {
|
||||||
|
cfg.Ethstats.URL = ctx.GlobalString(utils.EthStatsURLFlag.Name)
|
||||||
|
}
|
||||||
|
|
||||||
return stack, cfg
|
return stack, cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,10 +143,12 @@ func makeFullNode(ctx *cli.Context) *node.Node {
|
||||||
if shhEnabled || shhAutoEnabled {
|
if shhEnabled || shhAutoEnabled {
|
||||||
utils.RegisterShhService(stack)
|
utils.RegisterShhService(stack)
|
||||||
}
|
}
|
||||||
// Add the Ethereum Stats daemon if requested
|
|
||||||
if url := ctx.GlobalString(utils.EthStatsURLFlag.Name); url != "" {
|
// Add the Ethereum Stats daemon if requested.
|
||||||
utils.RegisterEthStatsService(stack, url)
|
if cfg.Ethstats.URL != "" {
|
||||||
|
utils.RegisterEthStatsService(stack, cfg.Ethstats.URL)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the release oracle service so it boots along with node.
|
// Add the release oracle service so it boots along with node.
|
||||||
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
|
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
|
||||||
config := release.Config{
|
config := release.Config{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue