Skip to content

Commit d5c3458

Browse files
committed
internal: fix downloader synchronising judgement
1 parent fa37595 commit d5c3458

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

eth/downloader/downloader.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,18 @@ func (d *Downloader) Progress() ethereum.SyncProgress {
253253
case LightSync:
254254
current = d.lightchain.CurrentHeader().Number.Uint64()
255255
}
256+
257+
// If the current block number is greater than the highest block number when synchronization started
258+
// due to pivot point moving, using the current block number as a replacement.
259+
highest := d.syncStatsChainHeight
260+
if current > highest {
261+
highest = current
262+
}
263+
256264
return ethereum.SyncProgress{
257265
StartingBlock: d.syncStatsChainOrigin,
258266
CurrentBlock: current,
259-
HighestBlock: d.syncStatsChainHeight,
267+
HighestBlock: highest,
260268
PulledStates: d.syncStatsState.processed,
261269
KnownStates: d.syncStatsState.processed + d.syncStatsState.pending,
262270
}

internal/ethapi/api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (s *PublicEthereumAPI) Syncing() (interface{}, error) {
8080
progress := s.b.Downloader().Progress()
8181

8282
// Return not syncing if the synchronisation already completed
83-
if progress.CurrentBlock >= progress.HighestBlock {
83+
if !s.b.Downloader().Synchronising() {
8484
return false, nil
8585
}
8686
// Otherwise gather the block sync stats

0 commit comments

Comments
 (0)