diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-03-23 23:36:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-23 23:36:38 +0800 |
commit | 8771c3061f340451d0966adcc547338a25f2231f (patch) | |
tree | c566cab81cf95a39f85fbe2c98a932af9495eb68 /cmd/geth | |
parent | 11e7a712f469fb24ddb88ecebcefab6ed8880eb8 (diff) | |
parent | 37dd9086ec491900311fc39837f4a62ef5fd3a4a (diff) | |
download | go-tangerine-8771c3061f340451d0966adcc547338a25f2231f.tar go-tangerine-8771c3061f340451d0966adcc547338a25f2231f.tar.gz go-tangerine-8771c3061f340451d0966adcc547338a25f2231f.tar.bz2 go-tangerine-8771c3061f340451d0966adcc547338a25f2231f.tar.lz go-tangerine-8771c3061f340451d0966adcc547338a25f2231f.tar.xz go-tangerine-8771c3061f340451d0966adcc547338a25f2231f.tar.zst go-tangerine-8771c3061f340451d0966adcc547338a25f2231f.zip |
Merge pull request #3794 from fjl/core-genesis-refactor
core: refactor genesis handling
Diffstat (limited to 'cmd/geth')
-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 } |