diff options
author | Felix Lange <fjl@twurst.com> | 2017-04-13 20:41:24 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2017-04-25 08:14:31 +0800 |
commit | 4047ccad2fb73fd2cfd69bf5b8cbfa788871ce0f (patch) | |
tree | 702ff4ccb7e70b4f9a063df145a13d2d54ad1292 /trie/trie.go | |
parent | a13e920af01692cb07a520cda688f1cc5b5469dd (diff) | |
download | dexon-4047ccad2fb73fd2cfd69bf5b8cbfa788871ce0f.tar dexon-4047ccad2fb73fd2cfd69bf5b8cbfa788871ce0f.tar.gz dexon-4047ccad2fb73fd2cfd69bf5b8cbfa788871ce0f.tar.bz2 dexon-4047ccad2fb73fd2cfd69bf5b8cbfa788871ce0f.tar.lz dexon-4047ccad2fb73fd2cfd69bf5b8cbfa788871ce0f.tar.xz dexon-4047ccad2fb73fd2cfd69bf5b8cbfa788871ce0f.tar.zst dexon-4047ccad2fb73fd2cfd69bf5b8cbfa788871ce0f.zip |
trie: add start key to NodeIterator constructors
The 'step' method is split into two parts, 'peek' and 'push'. peek
returns the next state but doesn't make it current.
The end of iteration was previously tracked by setting 'trie' to nil.
End of iteration is now tracked using the 'iteratorEnd' error, which is
slightly cleaner and requires less code.
Diffstat (limited to 'trie/trie.go')
-rw-r--r-- | trie/trie.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/trie/trie.go b/trie/trie.go index dbffc0ac3..5759f97e3 100644 --- a/trie/trie.go +++ b/trie/trie.go @@ -125,9 +125,10 @@ func New(root common.Hash, db Database) (*Trie, error) { return trie, nil } -// Iterator returns an iterator over all mappings in the trie. -func (t *Trie) NodeIterator() NodeIterator { - return newNodeIterator(t) +// NodeIterator returns an iterator that returns nodes of the trie. Iteration starts at +// the key after the given start key. +func (t *Trie) NodeIterator(start []byte) NodeIterator { + return newNodeIterator(t, start) } // Get returns the value for key stored in the trie. |