diff --git a/src/net_processing.cpp b/src/net_processing.cpp index e211ee3b2c6..48d2ce280a6 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1451,6 +1451,7 @@ void PeerManagerImpl::FindNextBlocks(std::vector& vBlocks, c { std::vector vToFetch; int nMaxHeight = std::min(state->pindexBestKnownBlock->nHeight, nWindowEnd + 1); + bool is_limited_peer = IsLimitedPeer(peer); NodeId waitingfor = -1; while (pindexWalk->nHeight < nMaxHeight) { // Read up to 128 (or more, if more blocks than that are needed) successors of pindexWalk (towards @@ -1505,6 +1506,11 @@ void PeerManagerImpl::FindNextBlocks(std::vector& vBlocks, c return; } + // Don't request blocks that go further than what limited peers can provide + if (is_limited_peer && (state->pindexBestKnownBlock->nHeight - pindex->nHeight >= static_cast(NODE_NETWORK_LIMITED_MIN_BLOCKS) - 2 /* two blocks buffer for possible races */)) { + continue; + } + vBlocks.push_back(pindex); if (vBlocks.size() == count) { return;