Reverse relaxation of header downloader (#4064)

* Undo headers relaxation change

* Undo headers relaxation change

Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
This commit is contained in:
ledgerwatch 2022-05-04 07:46:52 +01:00 committed by GitHub
parent f590bf682f
commit 7c2a7150bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -241,8 +241,8 @@ func (hd *HeaderDownload) MarkPreverified(link *Link) {
if !link.persisted {
link.verified = true
hd.moveLinkToQueue(link, InsertQueueID)
link = hd.links[link.header.ParentHash]
}
link = hd.links[link.header.ParentHash]
}
}
@ -275,11 +275,13 @@ func (hd *HeaderDownload) extendUp(segment ChainSegment, attachmentLink *Link) {
prevLink := attachmentLink
for i := len(segment) - 1; i >= 0; i-- {
link := hd.addHeaderAsLink(segment[i], false /* persisted */)
// If we are attching to already persisted link, schedule for insertion (persistence)
if link.verified {
hd.moveLinkToQueue(link, InsertQueueID)
} else {
hd.moveLinkToQueue(link, VerifyQueueID)
if prevLink.persisted {
// If we are attching to already persisted link, schedule for insertion (persistence)
if link.verified {
hd.moveLinkToQueue(link, InsertQueueID)
} else {
hd.moveLinkToQueue(link, VerifyQueueID)
}
}
prevLink.next = append(prevLink.next, link)
prevLink = link
@ -363,10 +365,12 @@ func (hd *HeaderDownload) connect(segment ChainSegment, attachmentLink *Link, an
for i := len(segment) - 1; i >= 0; i-- {
link := hd.addHeaderAsLink(segment[i], false /* persisted */)
// If we attach to already persisted link, mark this one for insertion
if link.verified {
hd.moveLinkToQueue(link, InsertQueueID)
} else {
hd.moveLinkToQueue(link, VerifyQueueID)
if prevLink.persisted {
if link.verified {
hd.moveLinkToQueue(link, InsertQueueID)
} else {
hd.moveLinkToQueue(link, VerifyQueueID)
}
}
prevLink.next = append(prevLink.next, link)
prevLink = link