Fixed iterator for short nodes.

In some cases the iterator didn't properly return the correct key
because it didn't append fields to the reverse lookup.
This commit is contained in:
obscuren
2014-11-20 18:11:31 +01:00
parent b05e63c34d
commit 12f1aea38d
3 changed files with 9 additions and 4 deletions

View File

@ -65,9 +65,9 @@ func (self *Iterator) next(node Node, key []byte) []byte {
}
} else {
cnode := node.Value()
skey := key[len(k):]
var ret []byte
skey := key[len(k):]
if trie.BeginsWith(key, k) {
ret = self.next(cnode, skey)
} else if bytes.Compare(k, key[:len(k)]) > 0 {
@ -93,7 +93,8 @@ func (self *Iterator) key(node Node) []byte {
return k
} else {
return self.key(node.Value())
k := trie.RemTerm(node.Key())
return append(k, self.key(node.Value())...)
}
case *FullNode:
if node.Value() != nil {