fix: PoW re-sync downloads already processed blocks#11514
fix: PoW re-sync downloads already processed blocks#11514
Conversation
|
Claude finished @batrr's task in 2m 48s —— View job Code Review
SummaryThe fix is correct and well-targeted. The root cause is accurately identified: when the same peer is re-allocated for a re-sync, The test correctly exercises the scenario: first full sync to block 10, P2P-propagated headers advance FindingsNo Critical / High / Medium issues. Low — Stale TODO comment now addressed
// Provide a way so that it does not redownload if part of the. I guess it does not care about skiplastn and maxheaders.
// TODO: Unit test this mechanism.The Low —
|
After a successful sync, if a re-sync is triggered (block gap, etc.) and the same best peer is re-allocated,
_currentBestPeerstill holds the stale reference soOnNewBestPeeris never called. This leaves_currentNumberstale, causing the downloader to re-request already-processed headers.Changes
_currentBestPeerwhen sync finishes (peer returns no headers), so the next re-sync resets_currentNumbertoBestKnownNumberinstead of the stale position.Types of changes
Testing
Requires testing
If yes, did you write tests?