Skip to content

Commit b496cd2

Browse files
committed
fix: if configured pivot <= origin, start at origin. fix comment
1 parent 1bad9b2 commit b496cd2

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

consensus/XDPoS/engines/engine_v2/epochSwitch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
// Given header and its hash, get epoch switch info from the epoch switch block of that epoch,
14-
// headers is allow to be nil. headers contain header (as last item) and it parents if any, which can be used to avoid
14+
// headers is allow to be nil. if not nil, headers contain header (as last item) and its parents if any, which can be used to avoid
1515
// fetching from the database during recursive lookups (useful during VerifyHeaders).
1616
func (x *XDPoS_v2) getEpochSwitchInfo(chain consensus.ChainReader, headers []*types.Header, hash common.Hash) (*types.EpochSwitchInfo, error) {
1717
epochSwitchInfo, ok := x.epochSwitches.Get(hash)

eth/downloader/downloader.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,8 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td *big.I
511511
if mode == FastSync {
512512
if d.pivotNumber != 0 {
513513
// Use configured pivot block
514-
log.Info("Using configured pivot block", "number", d.pivotNumber)
514+
log.Info("Using configured pivot block", "number", d.pivotNumber, "origin", origin)
515515
pivot = d.pivotNumber
516-
if pivot <= origin {
517-
origin = pivot - 1
518-
}
519516
} else if height <= uint64(fsMinFullBlocks) {
520517
origin = 0
521518
} else {
@@ -529,6 +526,9 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td *big.I
529526
if mode == FastSync && pivot != 0 {
530527
d.committed = 0
531528
}
529+
if mode == FastSync && d.pivotNumber != 0 && pivot <= origin {
530+
d.committed = 1
531+
}
532532
// Initiate the sync using a concurrent header and content retrieval algorithm
533533
d.queue.Prepare(origin+1, mode)
534534
if d.syncInitHook != nil {

0 commit comments

Comments
 (0)