aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil/trie.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-06-30 20:28:54 +0800
committerobscuren <geffobscura@gmail.com>2014-06-30 20:28:54 +0800
commit82272ee08a7d72be1cc0947b6a0e8096a0353362 (patch)
tree4fe6fd457ac0689b63eb68ec5ae5980ac6429ade /ethutil/trie.go
parent9ed0d389b2402baf2dbc90fe12e9b4695ee22858 (diff)
downloadgo-tangerine-82272ee08a7d72be1cc0947b6a0e8096a0353362.tar
go-tangerine-82272ee08a7d72be1cc0947b6a0e8096a0353362.tar.gz
go-tangerine-82272ee08a7d72be1cc0947b6a0e8096a0353362.tar.bz2
go-tangerine-82272ee08a7d72be1cc0947b6a0e8096a0353362.tar.lz
go-tangerine-82272ee08a7d72be1cc0947b6a0e8096a0353362.tar.xz
go-tangerine-82272ee08a7d72be1cc0947b6a0e8096a0353362.tar.zst
go-tangerine-82272ee08a7d72be1cc0947b6a0e8096a0353362.zip
Iterator fix
Diffstat (limited to 'ethutil/trie.go')
-rw-r--r--ethutil/trie.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/ethutil/trie.go b/ethutil/trie.go
index 26a27a901..c669bdcb0 100644
--- a/ethutil/trie.go
+++ b/ethutil/trie.go
@@ -538,15 +538,13 @@ func (it *TrieIterator) fetchNode(key []int, node []byte, cb EachCallback) {
}
func (it *TrieIterator) iterateNode(key []int, currentNode *Value, cb EachCallback) {
- //fmt.Println("node", currentNode)
-
if currentNode.Len() == 2 {
k := CompactDecode(currentNode.Get(0).Str())
- if currentNode.Get(1).Str() == "" {
- it.iterateNode(key, currentNode.Get(1), cb)
+ pk := append(key, k...)
+ if currentNode.Get(1).Len() != 0 && currentNode.Get(1).Str() == "" {
+ it.iterateNode(pk, currentNode.Get(1), cb)
} else {
- pk := append(key, k...)
if k[len(k)-1] == 16 {
cb(DecodeCompact(pk), currentNode.Get(1))
@@ -560,7 +558,7 @@ func (it *TrieIterator) iterateNode(key []int, currentNode *Value, cb EachCallba
if i == 16 && currentNode.Get(i).Len() != 0 {
cb(DecodeCompact(pk), currentNode.Get(i))
} else {
- if currentNode.Get(i).Str() == "" {
+ if currentNode.Get(i).Len() != 0 && currentNode.Get(i).Str() == "" {
it.iterateNode(pk, currentNode.Get(i), cb)
} else {
val := currentNode.Get(i).Str()