internal: fix downloader synchronising judgement

This commit is contained in:
rjl493456442 2018-03-03 13:26:33 +08:00
parent fa375955ad
commit d5c3458b37
2 changed files with 10 additions and 2 deletions

View file

@ -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,
}

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