Skip to content

Commit 0dc8bf5

Browse files
committed
[net processing] Dont request compact blocks in blocks-only mode
1 parent efa227f commit 0dc8bf5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/net_processing.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,12 @@ bool PeerManagerImpl::BlockRequested(NodeId nodeid, const CBlockIndex& block, st
884884
void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid)
885885
{
886886
AssertLockHeld(cs_main);
887+
888+
// Never request high-bandwidth mode from peers if we're blocks-only. Our
889+
// mempool will not contain the transactions necessary to reconstruct the
890+
// compact block.
891+
if (m_ignore_incoming_txs) return;
892+
887893
CNodeState* nodestate = State(nodeid);
888894
if (!nodestate || !nodestate->fSupportsDesiredCmpctVersion) {
889895
// Never ask from peers who can't provide witnesses.
@@ -2165,7 +2171,11 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
21652171
pindexLast->GetBlockHash().ToString(), pindexLast->nHeight);
21662172
}
21672173
if (vGetData.size() > 0) {
2168-
if (nodestate->fSupportsDesiredCmpctVersion && vGetData.size() == 1 && mapBlocksInFlight.size() == 1 && pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) {
2174+
if (!m_ignore_incoming_txs &&
2175+
nodestate->fSupportsDesiredCmpctVersion &&
2176+
vGetData.size() == 1 &&
2177+
mapBlocksInFlight.size() == 1 &&
2178+
pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) {
21692179
// In any case, we want to download using a compact block, not a regular one
21702180
vGetData[0] = CInv(MSG_CMPCT_BLOCK, vGetData[0].hash);
21712181
}

0 commit comments

Comments
 (0)