diff options
author | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-07-26 03:48:53 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-07-26 03:48:53 +0800 |
commit | c1c895a36b420d58431cf483bd3ed602227892fc (patch) | |
tree | 3a8ad9acc57bc63c3f14c14911df900ed264d759 /core/chain_util.go | |
parent | 73a576c9af5038366f50509136a91a86d203fc6b (diff) | |
download | dexon-c1c895a36b420d58431cf483bd3ed602227892fc.tar.gz dexon-c1c895a36b420d58431cf483bd3ed602227892fc.tar.zst dexon-c1c895a36b420d58431cf483bd3ed602227892fc.zip |
core: fixed genesis write out to write only canon number
Diffstat (limited to 'core/chain_util.go')
-rw-r--r-- | core/chain_util.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/core/chain_util.go b/core/chain_util.go index a67fdb135..38273d2f0 100644 --- a/core/chain_util.go +++ b/core/chain_util.go @@ -111,13 +111,22 @@ func GetBlockByNumber(db common.Database, number uint64) *types.Block { return GetBlockByHash(db, common.BytesToHash(key)) } -// WriteHead force writes the current head -func WriteHead(db common.Database, block *types.Block) error { +// WriteCanonNumber writes the canonical hash for the given block +func WriteCanonNumber(db common.Database, block *types.Block) error { key := append(blockNumPre, block.Number().Bytes()...) err := db.Put(key, block.Hash().Bytes()) if err != nil { return err } + return nil +} + +// WriteHead force writes the current head +func WriteHead(db common.Database, block *types.Block) error { + err := WriteCanonNumber(db, block) + if err != nil { + return err + } err = db.Put([]byte("LastBlock"), block.Hash().Bytes()) if err != nil { return err |