aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2016-06-21 16:28:38 -0700
committerMarcoFalke <falke.marco@gmail.com>2016-11-20 15:07:53 +0100
commit76ba1c973948a33bbf87d13c4bd2f2b81fb466a2 (patch)
tree8850031f5ca501a2275cf5079489166920b03fde
parent36e3b951039b98508badaafa0bbec166c22900d3 (diff)
downloadbitcoin-76ba1c973948a33bbf87d13c4bd2f2b81fb466a2.tar.xz
More agressively filter compact block requests
Unit test adaptations by Pieter Wuille. Github-Pull: #8637 Rebased-From: fe998e962dc015978f104b782afb7daec3c4d4df
-rwxr-xr-xqa/rpc-tests/p2p-compactblocks.py4
-rw-r--r--src/main.cpp6
2 files changed, 5 insertions, 5 deletions
diff --git a/qa/rpc-tests/p2p-compactblocks.py b/qa/rpc-tests/p2p-compactblocks.py
index 249afec2b5..4029669780 100755
--- a/qa/rpc-tests/p2p-compactblocks.py
+++ b/qa/rpc-tests/p2p-compactblocks.py
@@ -594,7 +594,7 @@ class CompactBlocksTest(BitcoinTestFramework):
def test_getblocktxn_handler(self, node, test_node, version):
# bitcoind won't respond for blocks whose height is more than 15 blocks
# deep.
- MAX_GETBLOCKTXN_DEPTH = 15
+ MAX_GETBLOCKTXN_DEPTH = 10
chain_height = node.getblockcount()
current_height = chain_height
while (current_height >= chain_height - MAX_GETBLOCKTXN_DEPTH):
@@ -635,7 +635,7 @@ class CompactBlocksTest(BitcoinTestFramework):
def test_compactblocks_not_at_tip(self, node, test_node):
# Test that requesting old compactblocks doesn't work.
- MAX_CMPCTBLOCK_DEPTH = 11
+ MAX_CMPCTBLOCK_DEPTH = 6
new_blocks = []
for i in range(MAX_CMPCTBLOCK_DEPTH):
test_node.clear_block_announcement()
diff --git a/src/main.cpp b/src/main.cpp
index 3436caaf10..2e09b6cf75 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 (mi->second->nHeight >= chainActive.Height() - 10) {
+ if (CanDirectFetch(Params().GetConsensus()) && mi->second->nHeight >= chainActive.Height() - 5) {
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() - 15) {
- LogPrint("net", "Peer %d sent us a getblocktxn for a block > 15 deep", pfrom->id);
+ if (it->second->nHeight < chainActive.Height() - 10) {
+ LogPrint("net", "Peer %d sent us a getblocktxn for a block > 10 deep", pfrom->id);
return true;
}