diff options
author | Martin Zumsande <mzumsande@gmail.com> | 2024-02-29 16:15:34 -0500 |
---|---|---|
committer | Martin Zumsande <mzumsande@gmail.com> | 2024-08-06 16:04:37 -0400 |
commit | 49d569cb1fdd62a9da8dff51dccaf4680fe3d0eb (patch) | |
tree | f67a085c268f45e16b4e1955a34644aff49ccbea | |
parent | 7a885518d57c6eb818ebef5fd04a575f324ee8b2 (diff) |
p2p: For assumeutxo, download snapshot chain before background chain
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.
Only existing peers are affected by this bug.
-rw-r--r-- | src/net_processing.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 2c91b5cf0f..cdc7e90316 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1406,9 +1406,11 @@ void PeerManagerImpl::FindNextBlocksToDownload(const Peer& peer, unsigned int co return; } - if (state->pindexLastCommonBlock == nullptr) { - // Bootstrap quickly by guessing a parent of our best tip is the forking point. - // Guessing wrong in either direction is not a problem. + // Bootstrap quickly by guessing a parent of our best tip is the forking point. + // Guessing wrong in either direction is not a problem. + // Also reset pindexLastCommonBlock after a snapshot was loaded, so that blocks after the snapshot will be prioritised for download. + if (state->pindexLastCommonBlock == nullptr || + (snap_base && state->pindexLastCommonBlock->nHeight < snap_base->nHeight)) { state->pindexLastCommonBlock = m_chainman.ActiveChain()[std::min(state->pindexBestKnownBlock->nHeight, m_chainman.ActiveChain().Height())]; } |