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 /trie | |
parent | 3deded28a50398b8ce108c72f27ea861c1bce178 (diff) | |
parent | a40a91d60f978477fd2582487dfb5e83d4255bf4 (diff) | |
download | dexon-7633dfdc082e8a692ba8089732d353ad31b0a0d6.tar dexon-7633dfdc082e8a692ba8089732d353ad31b0a0d6.tar.gz dexon-7633dfdc082e8a692ba8089732d353ad31b0a0d6.tar.bz2 dexon-7633dfdc082e8a692ba8089732d353ad31b0a0d6.tar.lz dexon-7633dfdc082e8a692ba8089732d353ad31b0a0d6.tar.xz dexon-7633dfdc082e8a692ba8089732d353ad31b0a0d6.tar.zst dexon-7633dfdc082e8a692ba8089732d353ad31b0a0d6.zip |
Merge pull request #1305 from obscuren/database-error-check
core, ethdb, trie: validate database errors
Diffstat (limited to 'trie')
-rw-r--r-- | trie/cache.go | 8 | ||||
-rw-r--r-- | trie/trie_test.go | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/trie/cache.go b/trie/cache.go index 2143785fa..4c76c6cba 100644 --- a/trie/cache.go +++ b/trie/cache.go @@ -1,8 +1,10 @@ package trie +import "github.com/ethereum/go-ethereum/logger/glog" + type Backend interface { Get([]byte) ([]byte, error) - Put([]byte, []byte) + Put([]byte, []byte) error } type Cache struct { @@ -29,7 +31,9 @@ func (self *Cache) Put(key []byte, data []byte) { func (self *Cache) Flush() { for k, v := range self.store { - self.backend.Put([]byte(k), v) + if err := self.backend.Put([]byte(k), v); err != nil { + glog.Fatal("db write err:", err) + } } // This will eventually grow too large. We'd could diff --git a/trie/trie_test.go b/trie/trie_test.go index 16311aadf..9a58958d8 100644 --- a/trie/trie_test.go +++ b/trie/trie_test.go @@ -12,7 +12,7 @@ import ( type Db map[string][]byte func (self Db) Get(k []byte) ([]byte, error) { return self[string(k)], nil } -func (self Db) Put(k, v []byte) { self[string(k)] = v } +func (self Db) Put(k, v []byte) error { self[string(k)] = v; return nil } // Used for testing func NewEmpty() *Trie { |