Inverted lowestNum and highestNum in header downloader (#3301)

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This commit is contained in:
ledgerwatch 2022-01-19 16:25:53 +00:00 committed by GitHub
parent 8287b3eda1
commit 6704c48ed7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -979,9 +979,9 @@ func (hi *HeaderInserter) BestHeaderChanged() bool {
// speeds up visibility of new blocks
// It remember peerID - then later - if anchors created from segments will abandoned - this peerID gonna get Penalty
func (hd *HeaderDownload) ProcessSegment(segment ChainSegment, newBlock bool, peerID enode.ID) (requestMore bool, penalties []PenaltyItem) {
lowestNum := segment[0].Number
highest := segment[len(segment)-1]
highestNum := highest.Number
// ChainSegment is sorted in the order of descending block numbers, so the lowest is at the end, and the highest is in the beginning
highestNum := segment[0].Number
lowestNum := segment[len(segment)-1].Number
log.Trace("processSegment", "from", lowestNum, "to", highestNum)
hd.lock.Lock()
defer hd.lock.Unlock()
@ -997,7 +997,7 @@ func (hd *HeaderDownload) ProcessSegment(segment ChainSegment, newBlock bool, pe
return
}
if highestNum > hd.topSeenHeightPoW {
if newBlock || hd.seenAnnounces.Seen(highest.Hash) {
if newBlock || hd.seenAnnounces.Seen(segment[0].Hash) {
hd.topSeenHeightPoW = highestNum
}
}