Revert "Inverted lowestNum and highestNum in header downloader (#3301)" (#3468)

This reverts commit 6704c48ed7.

Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
This commit is contained in:
ledgerwatch 2022-02-10 12:23:40 +00:00 committed by GitHub
parent 79de194edf
commit 2e0602b8dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -990,9 +990,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) {
// 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
lowestNum := segment[0].Number
highest := segment[len(segment)-1]
highestNum := highest.Number
log.Trace("processSegment", "from", lowestNum, "to", highestNum)
hd.lock.Lock()
defer hd.lock.Unlock()
@ -1008,7 +1008,7 @@ func (hd *HeaderDownload) ProcessSegment(segment ChainSegment, newBlock bool, pe
return
}
if highestNum > hd.topSeenHeightPoW {
if newBlock || hd.seenAnnounces.Seen(segment[0].Hash) {
if newBlock || hd.seenAnnounces.Seen(highest.Hash) {
hd.topSeenHeightPoW = highestNum
}
}