diff options
author | zsfelfoldi <zsfelfoldi@gmail.com> | 2015-11-26 01:28:21 +0800 |
---|---|---|
committer | zsfelfoldi <zsfelfoldi@gmail.com> | 2015-12-01 08:38:32 +0800 |
commit | 52904ae32f0a591e7dccad7827ff1c2a73c27026 (patch) | |
tree | 9d6804d5b7594e57adb83dfd271598e37b81065d /trie/iterator.go | |
parent | 66d47ced4892141cdc955856b9fce6e95bca0402 (diff) | |
download | dexon-52904ae32f0a591e7dccad7827ff1c2a73c27026.tar.gz dexon-52904ae32f0a591e7dccad7827ff1c2a73c27026.tar.zst dexon-52904ae32f0a591e7dccad7827ff1c2a73c27026.zip |
trie: added error handling
Created alternate versions of Trie and SecureTrie functions that can return a MissingNodeError (used by ODR services)
Diffstat (limited to 'trie/iterator.go')
-rw-r--r-- | trie/iterator.go | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/trie/iterator.go b/trie/iterator.go index 38555fe08..5f205e081 100644 --- a/trie/iterator.go +++ b/trie/iterator.go @@ -16,7 +16,12 @@ package trie -import "bytes" +import ( + "bytes" + + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" +) type Iterator struct { trie *Trie @@ -100,7 +105,11 @@ func (self *Iterator) next(node interface{}, key []byte, isIterStart bool) []byt } case hashNode: - return self.next(self.trie.resolveHash(node), key, isIterStart) + rn, err := self.trie.resolveHash(node, nil, nil) + if err != nil && glog.V(logger.Error) { + glog.Errorf("Unhandled trie error: %v", err) + } + return self.next(rn, key, isIterStart) } return nil } @@ -127,7 +136,11 @@ func (self *Iterator) key(node interface{}) []byte { } } case hashNode: - return self.key(self.trie.resolveHash(node)) + rn, err := self.trie.resolveHash(node, nil, nil) + if err != nil && glog.V(logger.Error) { + glog.Errorf("Unhandled trie error: %v", err) + } + return self.key(rn) } return nil |