From d5c3458b3715af1b1e79ccf6e31225580d022a92 Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Sat, 3 Mar 2018 13:26:33 +0800 Subject: [PATCH] internal: fix downloader synchronising judgement --- eth/downloader/downloader.go | 10 +++++++++- internal/ethapi/api.go | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 70febf4cb1..2d20f1678d 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -253,10 +253,18 @@ func (d *Downloader) Progress() ethereum.SyncProgress { case LightSync: current = d.lightchain.CurrentHeader().Number.Uint64() } + + // If the current block number is greater than the highest block number when synchronization started + // due to pivot point moving, using the current block number as a replacement. + highest := d.syncStatsChainHeight + if current > highest { + highest = current + } + return ethereum.SyncProgress{ StartingBlock: d.syncStatsChainOrigin, CurrentBlock: current, - HighestBlock: d.syncStatsChainHeight, + HighestBlock: highest, PulledStates: d.syncStatsState.processed, KnownStates: d.syncStatsState.processed + d.syncStatsState.pending, } diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 20a060e727..8a2df64bd8 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