@@ -31,15 +31,14 @@ import (
31
31
type NodeIterator struct {
32
32
state * StateDB // State being iterated
33
33
34
- stateIt * trie.NodeIterator // Primary iterator for the global state trie
35
- dataIt * trie.NodeIterator // Secondary iterator for the data trie of a contract
34
+ stateIt trie.NodeIterator // Primary iterator for the global state trie
35
+ dataIt trie.NodeIterator // Secondary iterator for the data trie of a contract
36
36
37
37
accountHash common.Hash // Hash of the node containing the account
38
38
codeHash common.Hash // Hash of the contract source code
39
39
code []byte // Source code associated with a contract
40
40
41
41
Hash common.Hash // Hash of the current entry being iterated (nil if not standalone)
42
- Entry interface {} // Current state entry being iterated (internal representation)
43
42
Parent common.Hash // Hash of the first full ancestor node (nil if current is the root)
44
43
45
44
Error error // Failure set in case of an internal error in the iterator
@@ -80,9 +79,9 @@ func (it *NodeIterator) step() error {
80
79
}
81
80
// If we had data nodes previously, we surely have at least state nodes
82
81
if it .dataIt != nil {
83
- if cont := it .dataIt .Next (); ! cont {
84
- if it .dataIt .Error != nil {
85
- return it .dataIt .Error
82
+ if cont := it .dataIt .Next (true ); ! cont {
83
+ if it .dataIt .Error () != nil {
84
+ return it .dataIt .Error ()
86
85
}
87
86
it .dataIt = nil
88
87
}
@@ -94,15 +93,15 @@ func (it *NodeIterator) step() error {
94
93
return nil
95
94
}
96
95
// Step to the next state trie node, terminating if we're out of nodes
97
- if cont := it .stateIt .Next (); ! cont {
98
- if it .stateIt .Error != nil {
99
- return it .stateIt .Error
96
+ if cont := it .stateIt .Next (true ); ! cont {
97
+ if it .stateIt .Error () != nil {
98
+ return it .stateIt .Error ()
100
99
}
101
100
it .state , it .stateIt = nil , nil
102
101
return nil
103
102
}
104
103
// If the state trie node is an internal entry, leave as is
105
- if ! it .stateIt .Leaf {
104
+ if ! it .stateIt .Leaf () {
106
105
return nil
107
106
}
108
107
// Otherwise we've reached an account node, initiate data iteration
@@ -112,15 +111,15 @@ func (it *NodeIterator) step() error {
112
111
Root common.Hash
113
112
CodeHash []byte
114
113
}
115
- if err := rlp .Decode (bytes .NewReader (it .stateIt .LeafBlob ), & account ); err != nil {
114
+ if err := rlp .Decode (bytes .NewReader (it .stateIt .LeafBlob () ), & account ); err != nil {
116
115
return err
117
116
}
118
117
dataTrie , err := trie .New (account .Root , it .state .db )
119
118
if err != nil {
120
119
return err
121
120
}
122
121
it .dataIt = trie .NewNodeIterator (dataTrie )
123
- if ! it .dataIt .Next () {
122
+ if ! it .dataIt .Next (true ) {
124
123
it .dataIt = nil
125
124
}
126
125
if ! bytes .Equal (account .CodeHash , emptyCodeHash ) {
@@ -130,15 +129,15 @@ func (it *NodeIterator) step() error {
130
129
return fmt .Errorf ("code %x: %v" , account .CodeHash , err )
131
130
}
132
131
}
133
- it .accountHash = it .stateIt .Parent
132
+ it .accountHash = it .stateIt .Parent ()
134
133
return nil
135
134
}
136
135
137
136
// retrieve pulls and caches the current state entry the iterator is traversing.
138
137
// The method returns whether there are any more data left for inspection.
139
138
func (it * NodeIterator ) retrieve () bool {
140
139
// Clear out any previously set values
141
- it .Hash , it . Entry = common.Hash {}, nil
140
+ it .Hash = common.Hash {}
142
141
143
142
// If the iteration's done, return no available data
144
143
if it .state == nil {
@@ -147,14 +146,14 @@ func (it *NodeIterator) retrieve() bool {
147
146
// Otherwise retrieve the current entry
148
147
switch {
149
148
case it .dataIt != nil :
150
- it .Hash , it .Entry , it . Parent = it .dataIt .Hash , it .dataIt .Node , it . dataIt . Parent
149
+ it .Hash , it .Parent = it .dataIt .Hash () , it .dataIt .Parent ()
151
150
if it .Parent == (common.Hash {}) {
152
151
it .Parent = it .accountHash
153
152
}
154
153
case it .code != nil :
155
- it .Hash , it .Entry , it . Parent = it .codeHash , it . code , it .accountHash
154
+ it .Hash , it .Parent = it .codeHash , it .accountHash
156
155
case it .stateIt != nil :
157
- it .Hash , it .Entry , it . Parent = it .stateIt .Hash , it .stateIt .Node , it . stateIt . Parent
156
+ it .Hash , it .Parent = it .stateIt .Hash () , it .stateIt .Parent ()
158
157
}
159
158
return true
160
159
}
0 commit comments