@@ -119,17 +119,21 @@ static const int MAX_UNCONNECTING_HEADERS = 10;
119
119
/* * Minimum blocks required to signal NODE_NETWORK_LIMITED */
120
120
static const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288 ;
121
121
/* * Average delay between local address broadcasts */
122
- static constexpr std::chrono::hours AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL{ 24 } ;
122
+ static constexpr auto AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL = 24h ;
123
123
/* * Average delay between peer address broadcasts */
124
- static constexpr std::chrono::seconds AVG_ADDRESS_BROADCAST_INTERVAL{30 };
125
- /* * Average delay between trickled inventory transmissions in seconds.
126
- * Blocks and peers with noban permission bypass this, outbound peers get half this delay. */
127
- static const unsigned int INVENTORY_BROADCAST_INTERVAL = 5 ;
124
+ static constexpr auto AVG_ADDRESS_BROADCAST_INTERVAL = 30s;
125
+ /* * Average delay between trickled inventory transmissions for inbound peers.
126
+ * Blocks and peers with noban permission bypass this. */
127
+ static constexpr auto INBOUND_INVENTORY_BROADCAST_INTERVAL = 5s;
128
+ /* * Average delay between trickled inventory transmissions for outbound peers.
129
+ * Use a smaller delay as there is less privacy concern for them.
130
+ * Blocks and peers with noban permission bypass this. */
131
+ static constexpr auto OUTBOUND_INVENTORY_BROADCAST_INTERVAL = 2s;
128
132
/* * Maximum rate of inventory items to send per second.
129
133
* Limits the impact of low-fee transaction floods. */
130
134
static constexpr unsigned int INVENTORY_BROADCAST_PER_SECOND = 7 ;
131
135
/* * Maximum number of inventory items to send per transmission. */
132
- static constexpr unsigned int INVENTORY_BROADCAST_MAX = INVENTORY_BROADCAST_PER_SECOND * INVENTORY_BROADCAST_INTERVAL ;
136
+ static constexpr unsigned int INVENTORY_BROADCAST_MAX = INVENTORY_BROADCAST_PER_SECOND * count_seconds (INBOUND_INVENTORY_BROADCAST_INTERVAL) ;
133
137
/* * The number of most recently announced transactions a peer can request. */
134
138
static constexpr unsigned int INVENTORY_MAX_RECENT_RELAY = 3500 ;
135
139
/* * Verify that INVENTORY_MAX_RECENT_RELAY is enough to cache everything typically
@@ -138,9 +142,9 @@ static constexpr unsigned int INVENTORY_MAX_RECENT_RELAY = 3500;
138
142
* peers, and random variations in the broadcast mechanism. */
139
143
static_assert (INVENTORY_MAX_RECENT_RELAY >= INVENTORY_BROADCAST_PER_SECOND * UNCONDITIONAL_RELAY_DELAY / std::chrono::seconds{1 }, " INVENTORY_RELAY_MAX too low" );
140
144
/* * Average delay between feefilter broadcasts in seconds. */
141
- static constexpr unsigned int AVG_FEEFILTER_BROADCAST_INTERVAL = 10 * 60 ;
145
+ static constexpr auto AVG_FEEFILTER_BROADCAST_INTERVAL = 10min ;
142
146
/* * Maximum feefilter broadcast delay after significant change. */
143
- static constexpr unsigned int MAX_FEEFILTER_CHANGE_DELAY = 5 * 60 ;
147
+ static constexpr auto MAX_FEEFILTER_CHANGE_DELAY = 5min ;
144
148
/* * Maximum number of compact filters that may be requested with one getcfilters. See BIP 157. */
145
149
static constexpr uint32_t MAX_GETCFILTERS_SIZE = 1000 ;
146
150
/* * Maximum number of cf hashes that may be requested with one getcfheaders. See BIP 157. */
@@ -4669,10 +4673,9 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
4669
4673
if (pto->m_tx_relay ->nNextInvSend < current_time) {
4670
4674
fSendTrickle = true ;
4671
4675
if (pto->IsInboundConn ()) {
4672
- pto->m_tx_relay ->nNextInvSend = std::chrono::microseconds{ m_connman.PoissonNextSendInbound (count_microseconds ( current_time), INVENTORY_BROADCAST_INTERVAL)} ;
4676
+ pto->m_tx_relay ->nNextInvSend = m_connman.PoissonNextSendInbound (current_time, INBOUND_INVENTORY_BROADCAST_INTERVAL) ;
4673
4677
} else {
4674
- // Use half the delay for outbound peers, as there is less privacy concern for them.
4675
- pto->m_tx_relay ->nNextInvSend = PoissonNextSend (current_time, std::chrono::seconds{INVENTORY_BROADCAST_INTERVAL >> 1 });
4678
+ pto->m_tx_relay ->nNextInvSend = PoissonNextSend (current_time, OUTBOUND_INVENTORY_BROADCAST_INTERVAL);
4676
4679
}
4677
4680
}
4678
4681
@@ -4927,24 +4930,24 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
4927
4930
if (pto->m_tx_relay ->lastSentFeeFilter == MAX_FILTER) {
4928
4931
// Send the current filter if we sent MAX_FILTER previously
4929
4932
// and made it out of IBD.
4930
- pto->m_tx_relay ->nextSendTimeFeeFilter = count_microseconds (current_time) - 1 ;
4933
+ pto->m_tx_relay ->m_next_send_feefilter = 0us ;
4931
4934
}
4932
4935
}
4933
- if (count_microseconds ( current_time) > pto->m_tx_relay ->nextSendTimeFeeFilter ) {
4936
+ if (current_time > pto->m_tx_relay ->m_next_send_feefilter ) {
4934
4937
CAmount filterToSend = g_filter_rounder.round (currentFilter);
4935
4938
// We always have a fee filter of at least minRelayTxFee
4936
4939
filterToSend = std::max (filterToSend, ::minRelayTxFee.GetFeePerK ());
4937
4940
if (filterToSend != pto->m_tx_relay ->lastSentFeeFilter ) {
4938
4941
m_connman.PushMessage (pto, msgMaker.Make (NetMsgType::FEEFILTER, filterToSend));
4939
4942
pto->m_tx_relay ->lastSentFeeFilter = filterToSend;
4940
4943
}
4941
- pto->m_tx_relay ->nextSendTimeFeeFilter = PoissonNextSend (count_microseconds ( current_time) , AVG_FEEFILTER_BROADCAST_INTERVAL);
4944
+ pto->m_tx_relay ->m_next_send_feefilter = PoissonNextSend (current_time, AVG_FEEFILTER_BROADCAST_INTERVAL);
4942
4945
}
4943
4946
// If the fee filter has changed substantially and it's still more than MAX_FEEFILTER_CHANGE_DELAY
4944
4947
// until scheduled broadcast, then move the broadcast to within MAX_FEEFILTER_CHANGE_DELAY.
4945
- else if (count_microseconds ( current_time) + MAX_FEEFILTER_CHANGE_DELAY * 1000000 < pto->m_tx_relay ->nextSendTimeFeeFilter &&
4948
+ else if (current_time + MAX_FEEFILTER_CHANGE_DELAY < pto->m_tx_relay ->m_next_send_feefilter &&
4946
4949
(currentFilter < 3 * pto->m_tx_relay ->lastSentFeeFilter / 4 || currentFilter > 4 * pto->m_tx_relay ->lastSentFeeFilter / 3 )) {
4947
- pto->m_tx_relay ->nextSendTimeFeeFilter = count_microseconds ( current_time) + GetRandInt (MAX_FEEFILTER_CHANGE_DELAY) * 1000000 ;
4950
+ pto->m_tx_relay ->m_next_send_feefilter = current_time + GetRandomDuration<std::chrono::microseconds> (MAX_FEEFILTER_CHANGE_DELAY);
4948
4951
}
4949
4952
}
4950
4953
} // release cs_main
0 commit comments