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

This commit is contained in:
rjl493456442 2018-03-08 12:33:38 +08:00
parent 3ec1b9a92d
commit ea04ad00fa
2 changed files with 9 additions and 1 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
}
d.syncStatsLock.Unlock()
// Signal the content downloaders of the availablility of new tasks
for _, ch := range []chan bool{d.bodyWakeCh, d.receiptWakeCh} {
select {

View file

@ -80,7 +80,7 @@ func (s *PublicEthereumAPI) Syncing() (interface{}, error) {
progress := s.b.Downloader().Progress()
// Return not syncing if the synchronisation already completed
if progress.CurrentBlock >= progress.HighestBlock {
if !s.b.Downloader().Synchronising() {
return false, nil
}
// Otherwise gather the block sync stats