File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -267,9 +267,16 @@ func (f *lightFetcher) announce(p *peer, head *announceData) {
267
267
}
268
268
n = n .parent
269
269
}
270
+ // n is now the reorg common ancestor, add a new branch of nodes
271
+ if n != nil && (head .Number >= n .number + maxNodeCount || head .Number <= n .number ) {
272
+ // if announced head block height is lower or same as n or too far from it to add
273
+ // intermediate nodes then discard previous announcement info and trigger a resync
274
+ n = nil
275
+ fp .nodeCnt = 0
276
+ fp .nodeByHash = make (map [common.Hash ]* fetcherTreeNode )
277
+ }
270
278
if n != nil {
271
- // n is now the reorg common ancestor, add a new branch of nodes
272
- // check if the node count is too high to add new nodes
279
+ // check if the node count is too high to add new nodes, discard oldest ones if necessary
273
280
locked := false
274
281
for uint64 (fp .nodeCnt )+ head .Number - n .number > maxNodeCount && fp .root != nil {
275
282
if ! locked {
You can’t perform that action at this time.
0 commit comments