diff options
Diffstat (limited to 'cmd/geth/chaincmd.go')
-rw-r--r-- | cmd/geth/chaincmd.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index 6ea474a9c..2d121a611 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -17,6 +17,7 @@ package main import ( + "encoding/json" "fmt" "os" "runtime" @@ -110,17 +111,22 @@ func initGenesis(ctx *cli.Context) error { stack := makeFullNode(ctx) chaindb := utils.MakeChainDatabase(ctx, stack) - genesisFile, err := os.Open(genesisPath) + file, err := os.Open(genesisPath) if err != nil { utils.Fatalf("failed to read genesis file: %v", err) } - defer genesisFile.Close() + defer file.Close() - block, err := core.WriteGenesisBlock(chaindb, genesisFile) + genesis := new(core.Genesis) + if err := json.NewDecoder(file).Decode(genesis); err != nil { + utils.Fatalf("invalid genesis file: %v", err) + } + + _, hash, err := core.SetupGenesisBlock(chaindb, genesis) if err != nil { utils.Fatalf("failed to write genesis block: %v", err) } - log.Info("Successfully wrote genesis state", "hash", block.Hash()) + log.Info("Successfully wrote genesis state", "hash", hash) return nil } |