mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 17:44:29 +00:00
Fix header skeleton (#2945)
* Fix underflow only * Rename queryRange to maxHeight * Fix additional cases
This commit is contained in:
parent
c1cbb21f3d
commit
3df4197f2e
@ -571,21 +571,22 @@ func (hd *HeaderDownload) RequestSkeleton() *HeaderRequest {
|
||||
defer hd.lock.RUnlock()
|
||||
log.Trace("Request skeleton", "anchors", len(hd.anchors), "top seen height", hd.topSeenHeight, "highestInDb", hd.highestInDb)
|
||||
stride := uint64(8 * 192)
|
||||
queryRange := hd.topSeenHeight
|
||||
nextHeight := hd.highestInDb + stride
|
||||
maxHeight := hd.topSeenHeight + 1 // Inclusive upper bound
|
||||
if maxHeight <= nextHeight {
|
||||
return nil
|
||||
}
|
||||
// Determine the query range as the height of lowest anchor
|
||||
for _, anchor := range hd.anchors {
|
||||
if anchor.blockHeight > hd.highestInDb && anchor.blockHeight < queryRange {
|
||||
queryRange = anchor.blockHeight
|
||||
if anchor.blockHeight > nextHeight && anchor.blockHeight < maxHeight {
|
||||
maxHeight = anchor.blockHeight // Exclusive upper bound
|
||||
}
|
||||
}
|
||||
length := (queryRange - hd.highestInDb) / stride
|
||||
length := (maxHeight - nextHeight) / stride
|
||||
if length > 192 {
|
||||
length = 192
|
||||
}
|
||||
if length == 0 {
|
||||
return nil
|
||||
}
|
||||
return &HeaderRequest{Number: hd.highestInDb + stride, Length: length, Skip: stride, Reverse: false}
|
||||
return &HeaderRequest{Number: nextHeight, Length: length, Skip: stride - 1, Reverse: false}
|
||||
}
|
||||
|
||||
// InsertHeaders attempts to insert headers into the database, verifying them first
|
||||
|
Loading…
Reference in New Issue
Block a user