Skip to content

Commit

Permalink
eth/downloader: fix data race around the ancientlimit (ethereum#21681)
Browse files Browse the repository at this point in the history
* eth/downloader: fix data race around the ancientlimit

* eth/downloader: initialize the ancientlimit as 0
  • Loading branch information
rjl493456442 authored and enriquefynn committed Feb 15, 2021
1 parent 3280718 commit d06aa21
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions eth/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td *big.I
d.ancientLimit = d.checkpoint
} else if height > fullMaxForkAncestry+1 {
d.ancientLimit = height - fullMaxForkAncestry - 1
} else {
d.ancientLimit = 0
}
frozen, _ := d.stateDB.Ancients() // Ignore the error here since light client can also hit here.

Expand Down Expand Up @@ -606,9 +608,6 @@ func (d *Downloader) cancel() {
func (d *Downloader) Cancel() {
d.cancel()
d.cancelWg.Wait()

d.ancientLimit = 0
log.Debug("Reset ancient limit to zero")
}

// Terminate interrupts the downloader, canceling all pending operations.
Expand Down

0 comments on commit d06aa21

Please sign in to comment.