Skip to content

Commit 26514f6

Browse files
mzumsandePiRK
authored andcommitted
p2p: For assumeutxo, download snapshot chain before background chain
Summary: After loading a snapshot, pindexLastCommonBlock is usually already set to some block for existing peers. That means we'd continue syncing the background chain from those peers instead of prioritising the snapshot chain, which defeats the purpose of doing assumeutxo in the first place. This is a backport of [[bitcoin/bitcoin#29519 | core#29519]] bitcoin/bitcoin@49d569c Depends on D18455 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D18456
1 parent 67ce874 commit 26514f6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/net_processing.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,9 +2025,13 @@ void PeerManagerImpl::FindNextBlocksToDownload(
20252025
return;
20262026
}
20272027

2028-
if (state->pindexLastCommonBlock == nullptr) {
2029-
// Bootstrap quickly by guessing a parent of our best tip is the forking
2030-
// point. Guessing wrong in either direction is not a problem.
2028+
// Bootstrap quickly by guessing a parent of our best tip is the forking
2029+
// point. Guessing wrong in either direction is not a problem. Also reset
2030+
// pindexLastCommonBlock after a snapshot was loaded, so that blocks after
2031+
// the snapshot will be prioritised for download.
2032+
if (state->pindexLastCommonBlock == nullptr ||
2033+
(snap_base &&
2034+
state->pindexLastCommonBlock->nHeight < snap_base->nHeight)) {
20312035
state->pindexLastCommonBlock =
20322036
m_chainman
20332037
.ActiveChain()[std::min(state->pindexBestKnownBlock->nHeight,

0 commit comments

Comments
 (0)