Skip to content

Commit 06731d1

Browse files
ajtownsfanquake
authored andcommitted
net_processing: Boost inv trickle rate
If transactions are being added to the mempool at a rate faster than 7tx/s (INVENTORY_BROADCAST_PER_SECOND) then peers' inventory_to_send queue can become relatively large. If this happens, increase the number of txids we include in an INV message (normally capped at 35) by 5 for each 1000 txids in the queue. This will tend to clear a temporary excess out reasonably quickly; an excess of 4000 invs to send will be cleared down to 1000 in about 30 minutes, while an excess of 20000 invs would be cleared down to 1000 in about 60 minutes. Github-Pull: #27610 Rebased-From: 5b34060
1 parent d0a2c87 commit 06731d1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/net_processing.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4890,7 +4890,9 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
48904890
// especially since we have many peers and some will draw much shorter delays.
48914891
unsigned int nRelayedTransactions = 0;
48924892
LOCK(pto->m_tx_relay->cs_filter);
4893-
while (!vInvTx.empty() && nRelayedTransactions < INVENTORY_BROADCAST_MAX) {
4893+
size_t broadcast_max{INVENTORY_BROADCAST_MAX + (pto->m_tx_relay->setInventoryTxToSend.size()/1000)*5};
4894+
broadcast_max = std::min<size_t>(1000, broadcast_max);
4895+
while (!vInvTx.empty() && nRelayedTransactions < broadcast_max) {
48944896
// Fetch the top element from the heap
48954897
std::pop_heap(vInvTx.begin(), vInvTx.end(), compareInvMempoolOrder);
48964898
std::set<uint256>::iterator it = vInvTx.back();

0 commit comments

Comments
 (0)