aboutsummaryrefslogtreecommitdiffstats
path: root/trie/iterator.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-04-18 19:37:10 +0800
committerFelix Lange <fjl@twurst.com>2017-04-25 08:14:31 +0800
commita13e920af01692cb07a520cda688f1cc5b5469dd (patch)
tree2321214787947ca0b4f302225aa2950617dd5cdd /trie/iterator.go
parentf958d7d4822d257598ae36fc3b381040faa5bb30 (diff)
downloaddexon-a13e920af01692cb07a520cda688f1cc5b5469dd.tar.gz
dexon-a13e920af01692cb07a520cda688f1cc5b5469dd.tar.zst
dexon-a13e920af01692cb07a520cda688f1cc5b5469dd.zip
trie: clean up iterator constructors
Make it so each iterator has exactly one public constructor: - NodeIterators can be created through a method. - Iterators can be created through NewIterator on any NodeIterator.
Diffstat (limited to 'trie/iterator.go')
-rw-r--r--trie/iterator.go15
1 files changed, 4 insertions, 11 deletions
diff --git a/trie/iterator.go b/trie/iterator.go
index dd63a0c5a..fef5b2593 100644
--- a/trie/iterator.go
+++ b/trie/iterator.go
@@ -31,15 +31,8 @@ type Iterator struct {
Value []byte // Current data value on which the iterator is positioned on
}
-// NewIterator creates a new key-value iterator.
-func NewIterator(trie *Trie) *Iterator {
- return &Iterator{
- nodeIt: NewNodeIterator(trie),
- }
-}
-
-// FromNodeIterator creates a new key-value iterator from a node iterator
-func NewIteratorFromNodeIterator(it NodeIterator) *Iterator {
+// NewIterator creates a new key-value iterator from a node iterator
+func NewIterator(it NodeIterator) *Iterator {
return &Iterator{
nodeIt: it,
}
@@ -99,8 +92,8 @@ type nodeIterator struct {
path []byte // Path to the current node
}
-// NewNodeIterator creates an post-order trie iterator.
-func NewNodeIterator(trie *Trie) NodeIterator {
+// newNodeIterator creates an post-order trie iterator.
+func newNodeIterator(trie *Trie) NodeIterator {
if trie.Hash() == emptyState {
return new(nodeIterator)
}