Skip to content

Commit d35efe1

Browse files
p2p: Start downloading historical blocks from common ancestor
Otherwise, if the background tip is not an ancestor of the snapshot, blocks in between that ancestor up to the height of the background tip will never be requested. Co-authored-by: Martin Zumsande <[email protected]> Co-authored-by: Alfonso Roman Zubeldia <[email protected]>
1 parent f47cd64 commit d35efe1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/net_processing.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6293,10 +6293,13 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
62936293
// before the background chainstate to prioritize getting to network tip.
62946294
FindNextBlocksToDownload(*peer, get_inflight_budget(), vToDownload, staller);
62956295
if (m_chainman.BackgroundSyncInProgress() && !IsLimitedPeer(*peer)) {
6296+
// If the background tip is not an ancestor of the snapshot block,
6297+
// we need to start requesting blocks from their last common ancestor.
6298+
const CBlockIndex *from_tip = LastCommonAncestor(m_chainman.GetBackgroundSyncTip(), m_chainman.GetSnapshotBaseBlock());
62966299
TryDownloadingHistoricalBlocks(
62976300
*peer,
62986301
get_inflight_budget(),
6299-
vToDownload, m_chainman.GetBackgroundSyncTip(),
6302+
vToDownload, from_tip,
63006303
Assert(m_chainman.GetSnapshotBaseBlock()));
63016304
}
63026305
for (const CBlockIndex *pindex : vToDownload) {

0 commit comments

Comments
 (0)