From 78b70d79ecdf9cde1b38855101840b19e365935c Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 1 Apr 2016 21:54:51 +0200 Subject: [PATCH] cmd/utils: fix geth startup with empty database --- cmd/utils/flags.go | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 3f54b40caf..5c0c3c6144 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.