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) */