Skip to content

Commit 905ed10

Browse files
authored
eth/downloader: fix data race around the ancientlimit (#21681)
* eth/downloader: fix data race around the ancientlimit * eth/downloader: initialize the ancientlimit as 0
1 parent 43cd31e commit 905ed10

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

eth/downloader/downloader.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,8 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td *big.I
515515
d.ancientLimit = d.checkpoint
516516
} else if height > fullMaxForkAncestry+1 {
517517
d.ancientLimit = height - fullMaxForkAncestry - 1
518+
} else {
519+
d.ancientLimit = 0
518520
}
519521
frozen, _ := d.stateDB.Ancients() // Ignore the error here since light client can also hit here.
520522

@@ -606,9 +608,6 @@ func (d *Downloader) cancel() {
606608
func (d *Downloader) Cancel() {
607609
d.cancel()
608610
d.cancelWg.Wait()
609-
610-
d.ancientLimit = 0
611-
log.Debug("Reset ancient limit to zero")
612611
}
613612

614613
// Terminate interrupts the downloader, canceling all pending operations.

0 commit comments

Comments
 (0)