Skip to content

Commit 3ac6de0

Browse files
committed
Align constant names for maximum compact block / blocktxn depth
1 parent b2e93a3 commit 3ac6de0

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

qa/rpc-tests/p2p-compactblocks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,9 @@ def test_getblocktxn_handler(self, node, test_node, version):
632632

633633
def test_compactblocks_not_at_tip(self, node, test_node):
634634
# Test that requesting old compactblocks doesn't work.
635-
MAX_CMPCTBLOCK_DEPTH = 6
635+
MAX_CMPCTBLOCK_DEPTH = 5
636636
new_blocks = []
637-
for i in range(MAX_CMPCTBLOCK_DEPTH):
637+
for i in range(MAX_CMPCTBLOCK_DEPTH + 1):
638638
test_node.clear_block_announcement()
639639
new_blocks.append(node.generate(1)[0])
640640
wait_until(test_node.received_block_announcement, timeout=30)

src/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4878,7 +4878,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
48784878
// and we don't feel like constructing the object for them, so
48794879
// instead we respond with the full, non-compact block.
48804880
bool fPeerWantsWitness = State(pfrom->GetId())->fWantsCmpctWitness;
4881-
if (CanDirectFetch(Params().GetConsensus()) && mi->second->nHeight >= chainActive.Height() - 5) {
4881+
if (CanDirectFetch(consensusParams) && mi->second->nHeight >= chainActive.Height() - MAX_CMPCTBLOCK_DEPTH) {
48824882
CBlockHeaderAndShortTxIDs cmpctblock(block, fPeerWantsWitness);
48834883
pfrom->PushMessageWithFlag(fPeerWantsWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS, NetMsgType::CMPCTBLOCK, cmpctblock);
48844884
} else
@@ -5405,8 +5405,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
54055405
return true;
54065406
}
54075407

5408-
if (it->second->nHeight < chainActive.Height() - 10) {
5409-
LogPrint("net", "Peer %d sent us a getblocktxn for a block > 10 deep", pfrom->id);
5408+
if (it->second->nHeight < chainActive.Height() - MAX_BLOCKTXN_DEPTH) {
5409+
LogPrint("net", "Peer %d sent us a getblocktxn for a block > %i deep", pfrom->id, MAX_BLOCKTXN_DEPTH);
54105410
return true;
54115411
}
54125412

src/main.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ static const unsigned int BLOCK_STALLING_TIMEOUT = 2;
9090
/** Number of headers sent in one getheaders result. We rely on the assumption that if a peer sends
9191
* less than this number, we reached its tip. Changing this value is a protocol upgrade. */
9292
static const unsigned int MAX_HEADERS_RESULTS = 2000;
93+
/** Maximum depth of blocks we're willing to serve as compact blocks to peers
94+
* when requested. For older blocks, a regular BLOCK response will be sent. */
95+
static const int MAX_CMPCTBLOCK_DEPTH = 5;
96+
/** Maximum depth of blocks we're willing to respond to GETBLOCKTXN requests for. */
97+
static const int MAX_BLOCKTXN_DEPTH = 10;
9398
/** Size of the "block download window": how far ahead of our current height do we fetch?
9499
* Larger windows tolerate larger download speed differences between peer, but increase the potential
95100
* degree of disordering of blocks on disk (which make reindexing and in the future perhaps pruning

0 commit comments

Comments
 (0)