eth/downloader: fix ancestor searching for light syncing (#19136)

ChrisChinchilla-patch-3
gary rong 6 years ago committed by Péter Szilágyi
parent 95b2ec7169
commit 6c312a24b6
  1. 6
      eth/downloader/downloader.go

@ -665,10 +665,12 @@ func (d *Downloader) findAncestor(p *peerConnection, remoteHeader *types.Header)
localHeight = d.lightchain.CurrentHeader().Number.Uint64()
}
p.log.Debug("Looking for common ancestor", "local", localHeight, "remote", remoteHeight)
// Recap floor value for binary search
if localHeight >= MaxForkAncestry {
// We're above the max reorg threshold, find the earliest fork point
floor = int64(localHeight - MaxForkAncestry)
}
// If we're doing a light sync, ensure the floor doesn't go below the CHT, as
// all headers before that point will be missing.
if d.mode == LightSync {
@ -688,7 +690,7 @@ func (d *Downloader) findAncestor(p *peerConnection, remoteHeader *types.Header)
floor = int64(d.genesis) - 1
}
}
}
from, count, skip, max := calculateRequestSpan(remoteHeight, localHeight)
p.log.Trace("Span searching for common ancestor", "count", count, "from", from, "skip", skip)

Loading…
Cancel
Save