Skip to content

Commit 47520ed

Browse files
committed
[net processing] Make fee filter rounder non-global
1 parent 77506f4 commit 47520ed

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/net_processing.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,8 @@ class PeerManagerImpl final : public PeerManager
697697

698698
FastRandomContext m_rng GUARDED_BY(NetEventsInterface::g_msgproc_mutex);
699699

700+
FeeFilterRounder m_fee_filter_rounder GUARDED_BY(NetEventsInterface::g_msgproc_mutex);
701+
700702
const CChainParams& m_chainparams;
701703
CConnman& m_connman;
702704
AddrMan& m_addrman;
@@ -1811,6 +1813,7 @@ PeerManagerImpl::PeerManagerImpl(CConnman& connman, AddrMan& addrman,
18111813
BanMan* banman, ChainstateManager& chainman,
18121814
CTxMemPool& pool, Options opts)
18131815
: m_rng{opts.deterministic_rng},
1816+
m_fee_filter_rounder{CFeeRate{DEFAULT_MIN_RELAY_TX_FEE}},
18141817
m_chainparams(chainman.GetParams()),
18151818
m_connman(connman),
18161819
m_addrman(addrman),
@@ -5338,22 +5341,21 @@ void PeerManagerImpl::MaybeSendFeefilter(CNode& pto, Peer& peer, std::chrono::mi
53385341
if (pto.IsBlockOnlyConn()) return;
53395342

53405343
CAmount currentFilter = m_mempool.GetMinFee().GetFeePerK();
5341-
static FeeFilterRounder g_filter_rounder{CFeeRate{DEFAULT_MIN_RELAY_TX_FEE}};
53425344

53435345
if (m_chainman.IsInitialBlockDownload()) {
53445346
// Received tx-inv messages are discarded when the active
53455347
// chainstate is in IBD, so tell the peer to not send them.
53465348
currentFilter = MAX_MONEY;
53475349
} else {
5348-
static const CAmount MAX_FILTER{g_filter_rounder.round(MAX_MONEY)};
5350+
static const CAmount MAX_FILTER{m_fee_filter_rounder.round(MAX_MONEY)};
53495351
if (peer.m_fee_filter_sent == MAX_FILTER) {
53505352
// Send the current filter if we sent MAX_FILTER previously
53515353
// and made it out of IBD.
53525354
peer.m_next_send_feefilter = 0us;
53535355
}
53545356
}
53555357
if (current_time > peer.m_next_send_feefilter) {
5356-
CAmount filterToSend = g_filter_rounder.round(currentFilter);
5358+
CAmount filterToSend = m_fee_filter_rounder.round(currentFilter);
53575359
// We always have a fee filter of at least the min relay fee
53585360
filterToSend = std::max(filterToSend, m_mempool.m_min_relay_feerate.GetFeePerK());
53595361
if (filterToSend != peer.m_fee_filter_sent) {

0 commit comments

Comments
 (0)