diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2016-08-31 17:35:59 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2016-11-20 15:08:16 +0100 |
commit | 2cad5db6f752ad8fa2d047b67a137de76eb9c982 (patch) | |
tree | 7ae8cd2ba5acdd9c7bda8215d51ef67e64833966 /src | |
parent | 3d23a0eaa3cfa349833e42345daf954e9530bdfd (diff) |
Align constant names for maximum compact block / blocktxn depth
Github-Pull: #8637
Rebased-From: 3ac6de0a045cc9b2047ceb19af970e7ffbf905fa
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 6 | ||||
-rw-r--r-- | src/main.h | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp index 2e09b6cf75..db020a4495 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4855,7 +4855,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam // and we don't feel like constructing the object for them, so // instead we respond with the full, non-compact block. bool fPeerWantsWitness = State(pfrom->GetId())->fWantsCmpctWitness; - if (CanDirectFetch(Params().GetConsensus()) && mi->second->nHeight >= chainActive.Height() - 5) { + if (CanDirectFetch(consensusParams) && mi->second->nHeight >= chainActive.Height() - MAX_CMPCTBLOCK_DEPTH) { CBlockHeaderAndShortTxIDs cmpctblock(block, fPeerWantsWitness); pfrom->PushMessageWithFlag(fPeerWantsWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS, NetMsgType::CMPCTBLOCK, cmpctblock); } else @@ -5401,8 +5401,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, return true; } - if (it->second->nHeight < chainActive.Height() - 10) { - LogPrint("net", "Peer %d sent us a getblocktxn for a block > 10 deep", pfrom->id); + if (it->second->nHeight < chainActive.Height() - MAX_BLOCKTXN_DEPTH) { + LogPrint("net", "Peer %d sent us a getblocktxn for a block > %i deep", pfrom->id, MAX_BLOCKTXN_DEPTH); return true; } diff --git a/src/main.h b/src/main.h index daf884337d..024f35cd39 100644 --- a/src/main.h +++ b/src/main.h @@ -89,6 +89,11 @@ static const unsigned int BLOCK_STALLING_TIMEOUT = 2; /** Number of headers sent in one getheaders result. We rely on the assumption that if a peer sends * less than this number, we reached its tip. Changing this value is a protocol upgrade. */ static const unsigned int MAX_HEADERS_RESULTS = 2000; +/** Maximum depth of blocks we're willing to serve as compact blocks to peers + * when requested. For older blocks, a regular BLOCK response will be sent. */ +static const int MAX_CMPCTBLOCK_DEPTH = 5; +/** Maximum depth of blocks we're willing to respond to GETBLOCKTXN requests for. */ +static const int MAX_BLOCKTXN_DEPTH = 10; /** Size of the "block download window": how far ahead of our current height do we fetch? * Larger windows tolerate larger download speed differences between peer, but increase the potential * degree of disordering of blocks on disk (which make reindexing and in the future perhaps pruning |