aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorMartin Zumsande <mzumsande@gmail.com>2024-06-10 18:20:15 -0400
committerAlfonso Roman Zubeldia <19962151+alfonsoromanz@users.noreply.github.com>2024-06-29 14:07:34 +0200
commitd35efe1efc0dbeae0667baade2a40be08511c13e (patch)
treec3a18c64e02d64a5a824763848f3a24aa4cf5827 /src/net_processing.cpp
parentf47cd649e970b37fcd1fc31bbadaebf49566ee73 (diff)
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 <mzumsande@gmail.com> Co-authored-by: Alfonso Roman Zubeldia <19962151+alfonsoromanz@users.noreply.github.com>
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 6374cb52c1..babff0796f 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -6293,10 +6293,13 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
// before the background chainstate to prioritize getting to network tip.
FindNextBlocksToDownload(*peer, get_inflight_budget(), vToDownload, staller);
if (m_chainman.BackgroundSyncInProgress() && !IsLimitedPeer(*peer)) {
+ // If the background tip is not an ancestor of the snapshot block,
+ // we need to start requesting blocks from their last common ancestor.
+ const CBlockIndex *from_tip = LastCommonAncestor(m_chainman.GetBackgroundSyncTip(), m_chainman.GetSnapshotBaseBlock());
TryDownloadingHistoricalBlocks(
*peer,
get_inflight_budget(),
- vToDownload, m_chainman.GetBackgroundSyncTip(),
+ vToDownload, from_tip,
Assert(m_chainman.GetSnapshotBaseBlock()));
}
for (const CBlockIndex *pindex : vToDownload) {