diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-06-22 07:49:14 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-06-22 07:49:14 +0800 |
commit | 7633dfdc082e8a692ba8089732d353ad31b0a0d6 (patch) | |
tree | 362ea86e1edf2228fe750725d4703bf4512d6c9e /core | |
parent | 3deded28a50398b8ce108c72f27ea861c1bce178 (diff) | |
parent | a40a91d60f978477fd2582487dfb5e83d4255bf4 (diff) | |
download | go-tangerine-7633dfdc082e8a692ba8089732d353ad31b0a0d6.tar.gz go-tangerine-7633dfdc082e8a692ba8089732d353ad31b0a0d6.tar.zst go-tangerine-7633dfdc082e8a692ba8089732d353ad31b0a0d6.zip |
Merge pull request #1305 from obscuren/database-error-check
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) } |