Skip to content

Commit

Permalink
eth/downloader: use a non-nil pivot even in degenerate sync requests
Browse files Browse the repository at this point in the history
  • Loading branch information
karalabe committed Jan 11, 2022
1 parent 5cf0685 commit 1e4f299
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions eth/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,6 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td *big.I
if err != nil {
return err
}
if mode == SnapSync && pivot == nil {
// If no pivot block was returned, the head is below the min full block
// threshold (i.e. new chain). In that case we won't really snap sync
// anyway, but still need a valid pivot block to avoid some code hitting
// nil panics on an access.
pivot = d.blockchain.CurrentBlock().Header()
}
} else {
// In beacon mode, user the skeleton chain to retrieve the headers from
latest, err = d.skeleton.Head()
Expand All @@ -489,6 +482,13 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td *big.I
// to special case everything internally.
pivot = d.skeleton.Header(latest.Number.Uint64() - 1)
}
// If no pivot block was returned, the head is below the min full block
// threshold (i.e. new chain). In that case we won't really snap sync
// anyway, but still need a valid pivot block to avoid some code hitting
// nil panics on access.
if mode == SnapSync && pivot == nil {
pivot = d.blockchain.CurrentBlock().Header()
}
height := latest.Number.Uint64()

var origin uint64
Expand Down

0 comments on commit 1e4f299

Please sign in to comment.