eth: update higest block we know during the sync if a higher was found (#16283)

* eth: update higest block we know during the sync if a higher was found

* eth: avoid useless sync in fast sync
This commit is contained in:
gary rong
2018-03-09 17:51:30 +08:00
committed by Péter Szilágyi
parent 307846d046
commit 77da203547
2 changed files with 16 additions and 0 deletions

View File

@ -1296,6 +1296,14 @@ func (d *Downloader) processHeaders(origin uint64, pivot uint64, td *big.Int) er
headers = headers[limit:]
origin += uint64(limit)
}
// Update the highest block number we know if a higher one is found.
d.syncStatsLock.Lock()
if d.syncStatsChainHeight < origin {
d.syncStatsChainHeight = origin - 1
}
d.syncStatsLock.Unlock()
// Signal the content downloaders of the availablility of new tasks
for _, ch := range []chan bool{d.bodyWakeCh, d.receiptWakeCh} {
select {