@@ -137,6 +137,9 @@ type pendingChangeNode struct {
137
137
nodes []* pendingChangeNode
138
138
}
139
139
140
+ // importNode method is called recursivelly until we found a node that import the pending change as one of
141
+ // its children. The node which should import the pending change must be a ancestor with a
142
+ // lower block number than the pending change.
140
143
func (c * pendingChangeNode ) importNode (blockHash common.Hash , blockNumber uint , pendingChange * pendingChange ,
141
144
isDescendantOf isDescendantOfFunc ) (imported bool , err error ) {
142
145
announcingHash := c .change .announcingHeader .Hash ()
@@ -145,6 +148,15 @@ func (c *pendingChangeNode) importNode(blockHash common.Hash, blockNumber uint,
145
148
return false , fmt .Errorf ("%w: %s" , errDuplicateHashes , blockHash )
146
149
}
147
150
151
+ isDescendant , err := isDescendantOf (announcingHash , blockHash )
152
+ if err != nil {
153
+ return false , fmt .Errorf ("cannot check ancestry: %w" , err )
154
+ }
155
+
156
+ if ! isDescendant {
157
+ return false , nil
158
+ }
159
+
148
160
if blockNumber <= c .change .announcingHeader .Number {
149
161
return false , nil
150
162
}
@@ -160,15 +172,6 @@ func (c *pendingChangeNode) importNode(blockHash common.Hash, blockNumber uint,
160
172
}
161
173
}
162
174
163
- isDescendant , err := isDescendantOf (announcingHash , blockHash )
164
- if err != nil {
165
- return false , fmt .Errorf ("cannot check ancestry: %w" , err )
166
- }
167
-
168
- if ! isDescendant {
169
- return false , nil
170
- }
171
-
172
175
childrenNode := & pendingChangeNode {change : pendingChange }
173
176
c .nodes = append (c .nodes , childrenNode )
174
177
return true , nil
0 commit comments