mirror of https://github.com/status-im/op-geth.git
Merge pull request #2409 from fjl/geth-fixup-init
cmd/geth: fix startup with empty database
This commit is contained in:
commit
96c7c39ae4
|
@ -359,6 +359,12 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
|
||||||
go metrics.CollectProcessMetrics(3 * time.Second)
|
go metrics.CollectProcessMetrics(3 * time.Second)
|
||||||
|
|
||||||
utils.SetupNetwork(ctx)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -772,23 +772,22 @@ func MustMakeChainConfig(ctx *cli.Context) *core.ChainConfig {
|
||||||
)
|
)
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
chainConfig, err := core.GetChainConfig(db, genesis.Hash())
|
if genesis != nil {
|
||||||
if err != nil {
|
// Exsting genesis block, use stored config if available.
|
||||||
if err != core.ChainConfigNotFoundErr {
|
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)
|
Fatalf("Could not make chain configuration: %v", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
var homesteadBlockNo *big.Int
|
var homesteadBlockNo *big.Int
|
||||||
if ctx.GlobalBool(TestNetFlag.Name) {
|
if ctx.GlobalBool(TestNetFlag.Name) {
|
||||||
homesteadBlockNo = params.TestNetHomesteadBlock
|
homesteadBlockNo = params.TestNetHomesteadBlock
|
||||||
} else {
|
} else {
|
||||||
homesteadBlockNo = params.MainNetHomesteadBlock
|
homesteadBlockNo = params.MainNetHomesteadBlock
|
||||||
}
|
}
|
||||||
|
return &core.ChainConfig{HomesteadBlock: homesteadBlockNo}
|
||||||
chainConfig = &core.ChainConfig{
|
|
||||||
HomesteadBlock: homesteadBlockNo,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return chainConfig
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MakeChainDatabase open an LevelDB using the flags passed to the client and will hard crash if it fails.
|
// MakeChainDatabase open an LevelDB using the flags passed to the client and will hard crash if it fails.
|
||||||
|
|
|
@ -169,10 +169,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
||||||
|
|
||||||
// Load up any custom genesis block if requested
|
// Load up any custom genesis block if requested
|
||||||
if len(config.Genesis) > 0 {
|
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))
|
block, err := core.WriteGenesisBlock(chainDb, strings.NewReader(config.Genesis))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in New Issue