diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-04-02 17:40:25 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-04-02 17:40:25 +0800 |
commit | 96c7c39ae4a031a508b0470ff2b1a95f0f3f9e51 (patch) | |
tree | 394b3366a84ed3460233848849e84a96025fb2d4 | |
parent | fb578f4550a08617485d9146876489d1f3bb1b52 (diff) | |
parent | cf842b3fe5ad497ef8dfd24c9179bc2fadbc707f (diff) | |
download | dexon-96c7c39ae4a031a508b0470ff2b1a95f0f3f9e51.tar dexon-96c7c39ae4a031a508b0470ff2b1a95f0f3f9e51.tar.gz dexon-96c7c39ae4a031a508b0470ff2b1a95f0f3f9e51.tar.bz2 dexon-96c7c39ae4a031a508b0470ff2b1a95f0f3f9e51.tar.lz dexon-96c7c39ae4a031a508b0470ff2b1a95f0f3f9e51.tar.xz dexon-96c7c39ae4a031a508b0470ff2b1a95f0f3f9e51.tar.zst dexon-96c7c39ae4a031a508b0470ff2b1a95f0f3f9e51.zip |
Merge pull request #2409 from fjl/geth-fixup-init
cmd/geth: fix startup with empty database
-rw-r--r-- | cmd/geth/main.go | 6 | ||||
-rw-r--r-- | cmd/utils/flags.go | 27 | ||||
-rw-r--r-- | eth/backend.go | 4 |
3 files changed, 19 insertions, 18 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 5d5ab4559..3a6366f4d 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -359,6 +359,12 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso go metrics.CollectProcessMetrics(3 * time.Second) utils.SetupNetwork(ctx) + + // Deprecation warning. + if ctx.GlobalIsSet(utils.GenesisFileFlag.Name) { + common.PrintDepricationWarning("--genesis is deprecated. Switch to use 'geth init /path/to/file'") + } + return nil } diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 3f54b40ca..5c0c3c614 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -772,23 +772,22 @@ func MustMakeChainConfig(ctx *cli.Context) *core.ChainConfig { ) defer db.Close() - chainConfig, err := core.GetChainConfig(db, genesis.Hash()) - if err != nil { - if err != core.ChainConfigNotFoundErr { + if genesis != nil { + // Exsting genesis block, use stored config if available. + storedConfig, err := core.GetChainConfig(db, genesis.Hash()) + if err == nil { + return storedConfig + } else if err != core.ChainConfigNotFoundErr { Fatalf("Could not make chain configuration: %v", err) } - var homesteadBlockNo *big.Int - if ctx.GlobalBool(TestNetFlag.Name) { - homesteadBlockNo = params.TestNetHomesteadBlock - } else { - homesteadBlockNo = params.MainNetHomesteadBlock - } - - chainConfig = &core.ChainConfig{ - HomesteadBlock: homesteadBlockNo, - } } - return chainConfig + var homesteadBlockNo *big.Int + if ctx.GlobalBool(TestNetFlag.Name) { + homesteadBlockNo = params.TestNetHomesteadBlock + } else { + homesteadBlockNo = params.MainNetHomesteadBlock + } + return &core.ChainConfig{HomesteadBlock: homesteadBlockNo} } // MakeChainDatabase open an LevelDB using the flags passed to the client and will hard crash if it fails. diff --git a/eth/backend.go b/eth/backend.go index 3c3440a53..26af7ff91 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -169,10 +169,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { // Load up any custom genesis block if requested if len(config.Genesis) > 0 { - // Using println instead of glog to make sure it **always** displays regardless of - // verbosity settings. - common.PrintDepricationWarning("--genesis is deprecated. Switch to use 'geth init /path/to/file'") - block, err := core.WriteGenesisBlock(chainDb, strings.NewReader(config.Genesis)) if err != nil { return nil, err |