From 31759a44d68a3513e5227ef9bb203fabdd352094 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 19 Sep 2018 15:04:03 +0300 Subject: [PATCH] Fix tx inv throughput (#2300) Bumps 4x per 1MB due to 4x smaller block times and accounts for blocks >1MB as in https://reviews.bitcoinabc.org/rABC4ae37d54ba3db21609ef8b704ed7f4377b9cece7 --- src/net_processing.cpp | 4 ++-- src/validation.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index b71c76d35..beba6989d 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3318,7 +3318,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic& interr std::vector vInv; { LOCK(pto->cs_inventory); - vInv.reserve(std::max(pto->vInventoryBlockToSend.size(), INVENTORY_BROADCAST_MAX)); + vInv.reserve(std::max(pto->vInventoryBlockToSend.size(), INVENTORY_BROADCAST_MAX_PER_1MB_BLOCK * MaxBlockSize(true) / 1000000)); // Add blocks BOOST_FOREACH(const uint256& hash, pto->vInventoryBlockToSend) { @@ -3387,7 +3387,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic& interr // especially since we have many peers and some will draw much shorter delays. unsigned int nRelayedTransactions = 0; LOCK(pto->cs_filter); - while (!vInvTx.empty() && nRelayedTransactions < INVENTORY_BROADCAST_MAX) { + while (!vInvTx.empty() && nRelayedTransactions < INVENTORY_BROADCAST_MAX_PER_1MB_BLOCK * MaxBlockSize(true) / 1000000) { // Fetch the top element from the heap std::pop_heap(vInvTx.begin(), vInvTx.end(), compareInvMempoolOrder); std::set::iterator it = vInvTx.back(); diff --git a/src/validation.h b/src/validation.h index 8c45bbb4e..91967b4e9 100644 --- a/src/validation.h +++ b/src/validation.h @@ -115,8 +115,9 @@ static const unsigned int AVG_ADDRESS_BROADCAST_INTERVAL = 30; * Blocks and whitelisted receivers bypass this, outbound peers get half this delay. */ static const unsigned int INVENTORY_BROADCAST_INTERVAL = 5; /** Maximum number of inventory items to send per transmission. - * Limits the impact of low-fee transaction floods. */ -static const unsigned int INVENTORY_BROADCAST_MAX = 7 * INVENTORY_BROADCAST_INTERVAL; + * Limits the impact of low-fee transaction floods. + * We have 4 times smaller block times in Dash, so we need to push 4 times more invs per 1MB. */ +static const unsigned int INVENTORY_BROADCAST_MAX_PER_1MB_BLOCK = 4 * 7 * INVENTORY_BROADCAST_INTERVAL; /** Block download timeout base, expressed in millionths of the block interval (i.e. 2.5 min) */ static const int64_t BLOCK_DOWNLOAD_TIMEOUT_BASE = 1000000; /** Additional block download timeout per parallel downloading peer (i.e. 1.25 min) */