Add comments about anchorQueue (#2382)

Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
This commit is contained in:
ledgerwatch 2021-07-16 12:46:08 +01:00 committed by GitHub
parent c0488ea919
commit eb5402ee05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -223,6 +223,9 @@ func (hd *HeaderDownload) extendDown(segment *ChainSegment, start, end int) (boo
}
}
// Anchor is removed from the map, but not from the anchorQueue
// This is because it is hard to find the index under which the anchor is stored in the anchorQueue
// But removal will happen anyway, in th function RequestMoreHeaders, if it disapppears from the map
delete(hd.anchors, anchor.parentHash)
// Add all headers in the segments as links to this anchor
var prevLink *Link
@ -275,6 +278,9 @@ func (hd *HeaderDownload) connect(segment *ChainSegment, start, end int) error {
break
}
}
// Anchor is removed from the map, but not from the anchorQueue
// This is because it is hard to find the index under which the anchor is stored in the anchorQueue
// But removal will happen anyway, in th function RequestMoreHeaders, if it disapppears from the map
delete(hd.anchors, anchor.parentHash)
// Iterate over headers backwards (from parents towards children)
prevLink := attachmentLink