From ea04ad00fa841e71e154daef6378ebcae1f97be0 Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Thu, 8 Mar 2018 12:33:38 +0800 Subject: [PATCH] eth: update higest block we know during the sync if a higher was found --- eth/downloader/downloader.go | 8 ++++++++ internal/ethapi/api.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 70febf4cb1..30316dfb66 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -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 { diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index e492444042..c8f73b0810 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -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