Skip to content

Commit

Permalink
core/state: unexport NodeIterator (ethereum#27239)
Browse files Browse the repository at this point in the history
  • Loading branch information
gballet authored May 11, 2023
1 parent d17ec0e commit 7577b9c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions core/state/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -44,17 +44,17 @@ 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,
}
}

// 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
Expand All @@ -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
Expand Down Expand Up @@ -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{}

Expand Down
2 changes: 1 addition & 1 deletion core/state/iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{}
}
Expand Down
2 changes: 1 addition & 1 deletion core/state/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7577b9c

Please sign in to comment.