diff --git a/core/state/iterator.go b/core/state/iterator.go index 79bb650abc..29c4abfc21 100644 --- a/core/state/iterator.go +++ b/core/state/iterator.go @@ -26,9 +26,9 @@ import ( "github.com/ethereum/go-ethereum/trie" ) -// nodeIterator is an iterator to traverse the entire state trie post-order, +// NodeIterator is an iterator to traverse the entire state trie post-order, // including all of the contract code and contract state tries. -type nodeIterator struct { +type NodeIterator struct { state *StateDB // State being iterated stateIt trie.NodeIterator // Primary iterator for the global state trie @@ -44,9 +44,9 @@ type nodeIterator struct { Error error // Failure set in case of an internal error in the iterator } -// newNodeIterator creates an post-order state node iterator. -func newNodeIterator(state *StateDB) *nodeIterator { - return &nodeIterator{ +// NewNodeIterator creates an post-order state node iterator. +func NewNodeIterator(state *StateDB) *NodeIterator { + return &NodeIterator{ state: state, } } @@ -54,7 +54,7 @@ func newNodeIterator(state *StateDB) *nodeIterator { // Next moves the iterator to the next node, returning whether there are any // further nodes. In case of an internal error this method returns false and // sets the Error field to the encountered failure. -func (it *nodeIterator) Next() bool { +func (it *NodeIterator) Next() bool { // If the iterator failed previously, don't do anything if it.Error != nil { return false @@ -68,7 +68,7 @@ func (it *nodeIterator) Next() bool { } // step moves the iterator to the next entry of the state trie. -func (it *nodeIterator) step() error { +func (it *NodeIterator) step() error { // Abort if we reached the end of the iteration if it.state == nil { return nil @@ -131,7 +131,7 @@ func (it *nodeIterator) step() error { // retrieve pulls and caches the current state entry the iterator is traversing. // The method returns whether there are any more data left for inspection. -func (it *nodeIterator) retrieve() bool { +func (it *NodeIterator) retrieve() bool { // Clear out any previously set values it.Hash = common.Hash{} diff --git a/core/state/iterator_test.go b/core/state/iterator_test.go index c8e1a181eb..24b192c26c 100644 --- a/core/state/iterator_test.go +++ b/core/state/iterator_test.go @@ -36,7 +36,7 @@ func TestNodeIteratorCoverage(t *testing.T) { } // Gather all the node hashes found by the iterator hashes := make(map[common.Hash]struct{}) - for it := newNodeIterator(state); it.Next(); { + for it := NewNodeIterator(state); it.Next(); { if it.Hash != (common.Hash{}) { hashes[it.Hash] = struct{}{} } diff --git a/core/state/sync_test.go b/core/state/sync_test.go index 8f8430559b..87621f49c1 100644 --- a/core/state/sync_test.go +++ b/core/state/sync_test.go @@ -125,7 +125,7 @@ func checkStateConsistency(db ethdb.Database, root common.Hash) error { if err != nil { return err } - it := newNodeIterator(state) + it := NewNodeIterator(state) for it.Next() { } return it.Error