diff options
author | obscuren <geffobscura@gmail.com> | 2015-06-21 02:31:11 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-06-21 22:59:15 +0800 |
commit | c590b505ed92957baf2ab4baa1788c6b0ec862cc (patch) | |
tree | 473ddb052798c30a21c05abef4764bccf4ab4e0a /core | |
parent | 3deded28a50398b8ce108c72f27ea861c1bce178 (diff) | |
download | dexon-c590b505ed92957baf2ab4baa1788c6b0ec862cc.tar.gz dexon-c590b505ed92957baf2ab4baa1788c6b0ec862cc.tar.zst dexon-c590b505ed92957baf2ab4baa1788c6b0ec862cc.zip |
core, ethdb, trie: validate database errors
Diffstat (limited to 'core')
-rw-r--r-- | core/chain_manager.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go index c3b7273c2..e3795f561 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -377,8 +377,14 @@ func (self *ChainManager) ExportN(w io.Writer, first uint64, last uint64) error // assumes that the `mu` mutex is held! func (bc *ChainManager) insert(block *types.Block) { key := append(blockNumPre, block.Number().Bytes()...) - bc.blockDb.Put(key, block.Hash().Bytes()) - bc.blockDb.Put([]byte("LastBlock"), block.Hash().Bytes()) + err := bc.blockDb.Put(key, block.Hash().Bytes()) + if err != nil { + glog.Fatal("db write fail:", err) + } + err = bc.blockDb.Put([]byte("LastBlock"), block.Hash().Bytes()) + if err != nil { + glog.Fatal("db write fail:", err) + } bc.currentBlock = block bc.lastBlockHash = block.Hash() @@ -387,7 +393,11 @@ func (bc *ChainManager) insert(block *types.Block) { func (bc *ChainManager) write(block *types.Block) { enc, _ := rlp.EncodeToBytes((*types.StorageBlock)(block)) key := append(blockHashPre, block.Hash().Bytes()...) - bc.blockDb.Put(key, enc) + err := bc.blockDb.Put(key, enc) + if err != nil { + glog.Fatal("db write fail:", err) + } + // Push block to cache bc.cache.Push(block) } |