net_processing: Clean up INVENTORY_BROADCAST_MAX constants
This commit is contained in:
1 parent
6fa49937e4
commit
1a118062fb
1 file changed
+8
-4
@@ -147,8 +147,12 @@ static constexpr auto OUTBOUND_INVENTORY_BROADCAST_INTERVAL{2s};
|
|||||||
/** Maximum rate of inventory items to send per second.
|
/** Maximum rate of inventory items to send per second.
|
||||||
* Limits the impact of low-fee transaction floods. */
|
* Limits the impact of low-fee transaction floods. */
|
||||||
static constexpr unsigned int INVENTORY_BROADCAST_PER_SECOND = 7;
|
static constexpr unsigned int INVENTORY_BROADCAST_PER_SECOND = 7;
|
||||||
|
/** Target number of tx inventory items to send per transmission. */
|
||||||
|
static constexpr unsigned int INVENTORY_BROADCAST_TARGET = INVENTORY_BROADCAST_PER_SECOND * count_seconds(INBOUND_INVENTORY_BROADCAST_INTERVAL);
|
||||||
/** Maximum number of inventory items to send per transmission. */
|
/** Maximum number of inventory items to send per transmission. */
|
||||||
static constexpr unsigned int INVENTORY_BROADCAST_MAX = INVENTORY_BROADCAST_PER_SECOND * count_seconds(INBOUND_INVENTORY_BROADCAST_INTERVAL);
|
static constexpr unsigned int INVENTORY_BROADCAST_MAX = 1000;
|
||||||
|
static_assert(INVENTORY_BROADCAST_MAX >= INVENTORY_BROADCAST_TARGET, "INVENTORY_BROADCAST_MAX too low");
|
||||||
|
static_assert(INVENTORY_BROADCAST_MAX <= MAX_PEER_TX_ANNOUNCEMENTS, "INVENTORY_BROADCAST_MAX too high");
|
||||||
/** Average delay between feefilter broadcasts in seconds. */
|
/** Average delay between feefilter broadcasts in seconds. */
|
||||||
static constexpr auto AVG_FEEFILTER_BROADCAST_INTERVAL{10min};
|
static constexpr auto AVG_FEEFILTER_BROADCAST_INTERVAL{10min};
|
||||||
/** Maximum feefilter broadcast delay after significant change. */
|
/** Maximum feefilter broadcast delay after significant change. */
|
||||||
@@ -5630,7 +5634,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
|||||||
std::vector<CInv> vInv;
|
std::vector<CInv> vInv;
|
||||||
{
|
{
|
||||||
LOCK(peer->m_block_inv_mutex);
|
LOCK(peer->m_block_inv_mutex);
|
||||||
vInv.reserve(std::max<size_t>(peer->m_blocks_for_inv_relay.size(), INVENTORY_BROADCAST_MAX));
|
vInv.reserve(std::max<size_t>(peer->m_blocks_for_inv_relay.size(), INVENTORY_BROADCAST_TARGET));
|
||||||
|
|
||||||
// Add blocks
|
// Add blocks
|
||||||
for (const uint256& hash : peer->m_blocks_for_inv_relay) {
|
for (const uint256& hash : peer->m_blocks_for_inv_relay) {
|
||||||
@@ -5707,8 +5711,8 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
|||||||
// especially since we have many peers and some will draw much shorter delays.
|
// especially since we have many peers and some will draw much shorter delays.
|
||||||
unsigned int nRelayedTransactions = 0;
|
unsigned int nRelayedTransactions = 0;
|
||||||
LOCK(tx_relay->m_bloom_filter_mutex);
|
LOCK(tx_relay->m_bloom_filter_mutex);
|
||||||
size_t broadcast_max{INVENTORY_BROADCAST_MAX + (tx_relay->m_tx_inventory_to_send.size()/1000)*5};
|
size_t broadcast_max{INVENTORY_BROADCAST_TARGET + (tx_relay->m_tx_inventory_to_send.size()/1000)*5};
|
||||||
broadcast_max = std::min<size_t>(1000, broadcast_max);
|
broadcast_max = std::min<size_t>(INVENTORY_BROADCAST_MAX, broadcast_max);
|
||||||
while (!vInvTx.empty() && nRelayedTransactions < broadcast_max) {
|
while (!vInvTx.empty() && nRelayedTransactions < broadcast_max) {
|
||||||
// Fetch the top element from the heap
|
// Fetch the top element from the heap
|
||||||
std::pop_heap(vInvTx.begin(), vInvTx.end(), compareInvMempoolOrder);
|
std::pop_heap(vInvTx.begin(), vInvTx.end(), compareInvMempoolOrder);
|
||||||
|
|||||||
Reference in new issue
Block a user