aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils/flags.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-10-29 18:33:57 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-10-29 22:07:07 +0800
commitf0dbec0c93a772b0f3553399126d8c49bfcc85d4 (patch)
treea3ced3d61ef6a5569752d549da6c13d27c344c48 /cmd/utils/flags.go
parent8639b0fae975a5e65dea16fe5321168ac0aef128 (diff)
downloaddexon-f0dbec0c93a772b0f3553399126d8c49bfcc85d4.tar
dexon-f0dbec0c93a772b0f3553399126d8c49bfcc85d4.tar.gz
dexon-f0dbec0c93a772b0f3553399126d8c49bfcc85d4.tar.bz2
dexon-f0dbec0c93a772b0f3553399126d8c49bfcc85d4.tar.lz
dexon-f0dbec0c93a772b0f3553399126d8c49bfcc85d4.tar.xz
dexon-f0dbec0c93a772b0f3553399126d8c49bfcc85d4.tar.zst
dexon-f0dbec0c93a772b0f3553399126d8c49bfcc85d4.zip
cmd, params: only set default fork configs for test and mainnet
Diffstat (limited to 'cmd/utils/flags.go')
-rw-r--r--cmd/utils/flags.go59
1 files changed, 34 insertions, 25 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 71777ce60..6c627ddcf 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -781,34 +781,43 @@ func MakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *core.ChainConfi
Fatalf("Could not make chain configuration: %v", err)
}
}
- // Set any missing fields due to them being unset or system upgrade
- if config.HomesteadBlock == nil {
- if ctx.GlobalBool(TestNetFlag.Name) {
- config.HomesteadBlock = params.TestNetHomesteadBlock
- } else {
- config.HomesteadBlock = params.MainNetHomesteadBlock
+ // Check whether we are allowed to set default config params or not:
+ // - If no genesis is set, we're running either mainnet or testnet (private nets use `geth init`)
+ // - If a genesis is already set, ensure we have a configuration for it (mainnet or testnet)
+ defaults := genesis == nil ||
+ (genesis.Hash() == params.MainNetGenesisHash && !ctx.GlobalBool(TestNetFlag.Name)) ||
+ (genesis.Hash() == params.TestNetGenesisHash && ctx.GlobalBool(TestNetFlag.Name))
+
+ // Set any missing chainConfig fields due to them being unset or system upgrade
+ if defaults {
+ if config.HomesteadBlock == nil {
+ if ctx.GlobalBool(TestNetFlag.Name) {
+ config.HomesteadBlock = params.TestNetHomesteadBlock
+ } else {
+ config.HomesteadBlock = params.MainNetHomesteadBlock
+ }
}
- }
- if config.DAOForkBlock == nil {
- if ctx.GlobalBool(TestNetFlag.Name) {
- config.DAOForkBlock = params.TestNetDAOForkBlock
- } else {
- config.DAOForkBlock = params.MainNetDAOForkBlock
+ if config.DAOForkBlock == nil {
+ if ctx.GlobalBool(TestNetFlag.Name) {
+ config.DAOForkBlock = params.TestNetDAOForkBlock
+ } else {
+ config.DAOForkBlock = params.MainNetDAOForkBlock
+ }
+ config.DAOForkSupport = true
}
- config.DAOForkSupport = true
- }
- if config.HomesteadGasRepriceBlock == nil {
- if ctx.GlobalBool(TestNetFlag.Name) {
- config.HomesteadGasRepriceBlock = params.TestNetHomesteadGasRepriceBlock
- } else {
- config.HomesteadGasRepriceBlock = params.MainNetHomesteadGasRepriceBlock
+ if config.HomesteadGasRepriceBlock == nil {
+ if ctx.GlobalBool(TestNetFlag.Name) {
+ config.HomesteadGasRepriceBlock = params.TestNetHomesteadGasRepriceBlock
+ } else {
+ config.HomesteadGasRepriceBlock = params.MainNetHomesteadGasRepriceBlock
+ }
}
- }
- if config.HomesteadGasRepriceHash == (common.Hash{}) {
- if ctx.GlobalBool(TestNetFlag.Name) {
- config.HomesteadGasRepriceHash = params.TestNetHomesteadGasRepriceHash
- } else {
- config.HomesteadGasRepriceHash = params.MainNetHomesteadGasRepriceHash
+ if config.HomesteadGasRepriceHash == (common.Hash{}) {
+ if ctx.GlobalBool(TestNetFlag.Name) {
+ config.HomesteadGasRepriceHash = params.TestNetHomesteadGasRepriceHash
+ } else {
+ config.HomesteadGasRepriceHash = params.MainNetHomesteadGasRepriceHash
+ }
}
}
// Force override any existing configs if explicitly requested