Skip to content

Commit 6dfee13

Browse files
committed
[net processing] Dont request compact blocks in blocks-only mode
1 parent 7a49fdc commit 6dfee13

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
@@ -831,6 +831,12 @@ bool PeerManagerImpl::BlockRequested(NodeId nodeid, const CBlockIndex& block, st
831831
void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid)
832832
{
833833
AssertLockHeld(cs_main);
834+
835+
// Never request high-bandwidth mode from peers if we're blocks-only. Our
836+
// mempool will not contain the transactions necessary to reconstruct the
837+
// compact block.
838+
if (m_ignore_incoming_txs) return;
839+
834840
CNodeState* nodestate = State(nodeid);
835841
if (!nodestate || !nodestate->fSupportsDesiredCmpctVersion) {
836842
// Never ask from peers who can't provide witnesses.
@@ -2116,7 +2122,11 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
21162122
pindexLast->GetBlockHash().ToString(), pindexLast->nHeight);
21172123
}
21182124
if (vGetData.size() > 0) {
2119-
if (nodestate->fSupportsDesiredCmpctVersion && vGetData.size() == 1 && mapBlocksInFlight.size() == 1 && pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) {
2125+
if (!m_ignore_incoming_txs &&
2126+
nodestate->fSupportsDesiredCmpctVersion &&
2127+
vGetData.size() == 1 &&
2128+
mapBlocksInFlight.size() == 1 &&
2129+
pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) {
21202130
// In any case, we want to download using a compact block, not a regular one
21212131
vGetData[0] = CInv(MSG_CMPCT_BLOCK, vGetData[0].hash);
21222132
}

0 commit comments

Comments
 (0)