Skip to content

Commit

Permalink
Exiting downloader after the sync is complete
Browse files Browse the repository at this point in the history
dominant-strategies#553 Link to the
issue to come back and revisit.
  • Loading branch information
gameofpointers authored and wizeguyy committed Jan 25, 2023
1 parent 072d020 commit 9536bb3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions eth/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func (d *Downloader) UnregisterPeer(id string) error {
func (d *Downloader) Synchronise(id string, head common.Hash, number uint64, mode SyncMode) error {
err := d.synchronise(id, head, number, mode)
switch err {
case nil, errBusy, errCanceled:
case nil, errBusy, errCanceled, errNoFetchesPending:
return err
}
if errors.Is(err, errInvalidChain) || errors.Is(err, errBadPeer) || errors.Is(err, errTimeout) ||
Expand Down Expand Up @@ -1153,10 +1153,10 @@ func (d *Downloader) processFullSyncContent(peerHeight uint64) error {
if err := d.importBlockResults(results); err != nil {
return err
}
}

if d.core.CurrentBlock().NumberU64() == peerHeight {
return nil
// If all the blocks are fetched, we exit the sync process
if results[0].Header.NumberU64() == peerHeight {
return errNoFetchesPending
}
}

// Come out of the for loop if the downloader cancel is invoked
Expand Down

0 comments on commit 9536bb3

Please sign in to comment.