mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
cmd/{geth,utils}: read genesis block from db in chain import
Signed-off-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
This commit is contained in:
parent
67a3b08795
commit
f5266f3e8f
2 changed files with 11 additions and 1 deletions
|
|
@ -290,7 +290,13 @@ func importChain(ctx *cli.Context) error {
|
||||||
stack, _ := makeConfigNode(ctx)
|
stack, _ := makeConfigNode(ctx)
|
||||||
defer stack.Close()
|
defer stack.Close()
|
||||||
|
|
||||||
chain, db := utils.MakeChain(ctx, stack, false)
|
db := utils.MakeChainDatabase(ctx, stack, false)
|
||||||
|
|
||||||
|
// if the error is not nil, no genesis is present in the db and so the default
|
||||||
|
// behavior of creating the genesis block applies.
|
||||||
|
genesis, _ := core.ReadGenesis(db)
|
||||||
|
|
||||||
|
chain, db := utils.MakeChainWithGenesisBlockAndChainDB(genesis, db, ctx, stack, false)
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
// Start periodically gathering memory profiles
|
// Start periodically gathering memory profiles
|
||||||
|
|
|
||||||
|
|
@ -2138,6 +2138,10 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
|
||||||
gspec = MakeGenesis(ctx)
|
gspec = MakeGenesis(ctx)
|
||||||
chainDb = MakeChainDatabase(ctx, stack, readonly)
|
chainDb = MakeChainDatabase(ctx, stack, readonly)
|
||||||
)
|
)
|
||||||
|
return MakeChainWithGenesisBlockAndChainDB(gspec, chainDb, ctx, stack, readonly)
|
||||||
|
}
|
||||||
|
|
||||||
|
func MakeChainWithGenesisBlockAndChainDB(gspec *core.Genesis, chainDb ethdb.Database, ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockChain, ethdb.Database) {
|
||||||
config, err := core.LoadChainConfig(chainDb, gspec)
|
config, err := core.LoadChainConfig(chainDb, gspec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fatalf("%v", err)
|
Fatalf("%v", err)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue