cmd, eth: fix dump config issue (#19825)

* eth: fix error when dump config with nil checkpoint

* cmd/utils: ignore default datadir if it's already set.
This commit is contained in:
gary rong 2019-07-11 19:37:08 +08:00 committed by Péter Szilágyi
parent 72029f0f88
commit 252150918c
3 changed files with 11 additions and 11 deletions

View File

@ -1202,11 +1202,11 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) {
cfg.DataDir = ctx.GlobalString(DataDirFlag.Name)
case ctx.GlobalBool(DeveloperFlag.Name):
cfg.DataDir = "" // unless explicitly requested, use memory databases
case ctx.GlobalBool(TestnetFlag.Name):
case ctx.GlobalBool(TestnetFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet")
case ctx.GlobalBool(RinkebyFlag.Name):
case ctx.GlobalBool(RinkebyFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby")
case ctx.GlobalBool(GoerliFlag.Name):
case ctx.GlobalBool(GoerliFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "goerli")
}
}

View File

@ -150,8 +150,8 @@ type Config struct {
RPCGasCap *big.Int `toml:",omitempty"`
// Checkpoint is a hardcoded checkpoint which can be nil.
Checkpoint *params.TrustedCheckpoint
Checkpoint *params.TrustedCheckpoint `toml:",omitempty"`
// CheckpointOracle is the configuration for checkpoint oracle.
CheckpointOracle *params.CheckpointOracleConfig
CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"`
}

View File

@ -47,8 +47,8 @@ func (c Config) MarshalTOML() (interface{}, error) {
EWASMInterpreter string
EVMInterpreter string
RPCGasCap *big.Int `toml:",omitempty"`
Checkpoint *params.TrustedCheckpoint
CheckpointOracle *params.CheckpointOracleConfig
Checkpoint *params.TrustedCheckpoint `toml:",omitempty"`
CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"`
}
var enc Config
enc.Genesis = c.Genesis
@ -117,8 +117,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
EWASMInterpreter *string
EVMInterpreter *string
RPCGasCap *big.Int `toml:",omitempty"`
Checkpoint *params.TrustedCheckpoint
CheckpointOracle *params.CheckpointOracleConfig
Checkpoint *params.TrustedCheckpoint `toml:",omitempty"`
CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"`
}
var dec Config
if err := unmarshal(&dec); err != nil {