@@ -470,7 +470,7 @@ class PeerManagerImpl final : public PeerManager
470470 *
471471 * Memory used: 1.3 MB
472472 */
473- std::unique_ptr< CRollingBloomFilter> recentRejects GUARDED_BY (cs_main);
473+ CRollingBloomFilter recentRejects GUARDED_BY (:: cs_main){ 120'000 , 0.000'001 } ;
474474 uint256 hashRecentRejectsChainTip GUARDED_BY (cs_main);
475475
476476 /*
@@ -1396,9 +1396,6 @@ PeerManagerImpl::PeerManagerImpl(const CChainParams& chainparams, CConnman& conn
13961396 m_mempool(pool),
13971397 m_ignore_incoming_txs(ignore_incoming_txs)
13981398{
1399- // Initialize global variables that cannot be constructed at startup.
1400- recentRejects.reset (new CRollingBloomFilter (120000 , 0.000001 ));
1401-
14021399 // Blocks don't typically have more than 4000 transactions, so this should
14031400 // be at least six blocks (~1 hr) worth of transactions that we can store,
14041401 // inserting both a txid and wtxid for every observed transaction.
@@ -1601,14 +1598,13 @@ void PeerManagerImpl::BlockChecked(const CBlock& block, const BlockValidationSta
16011598
16021599bool PeerManagerImpl::AlreadyHaveTx (const GenTxid& gtxid)
16031600{
1604- assert (recentRejects);
16051601 if (m_chainman.ActiveChain ().Tip ()->GetBlockHash () != hashRecentRejectsChainTip) {
16061602 // If the chain tip has changed previously rejected transactions
16071603 // might be now valid, e.g. due to a nLockTime'd tx becoming valid,
16081604 // or a double-spend. Reset the rejects filter and give those
16091605 // txs a second chance.
16101606 hashRecentRejectsChainTip = m_chainman.ActiveChain ().Tip ()->GetBlockHash ();
1611- recentRejects-> reset ();
1607+ recentRejects. reset ();
16121608 }
16131609
16141610 const uint256& hash = gtxid.GetHash ();
@@ -1620,7 +1616,7 @@ bool PeerManagerImpl::AlreadyHaveTx(const GenTxid& gtxid)
16201616 if (m_recent_confirmed_transactions->contains (hash)) return true ;
16211617 }
16221618
1623- return recentRejects-> contains (hash) || m_mempool.exists (gtxid);
1619+ return recentRejects. contains (hash) || m_mempool.exists (gtxid);
16241620}
16251621
16261622bool PeerManagerImpl::AlreadyHaveBlock (const uint256& block_hash)
@@ -2239,8 +2235,7 @@ void PeerManagerImpl::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
22392235 // See also comments in https://github.com/bitcoin/bitcoin/pull/18044#discussion_r443419034
22402236 // for concerns around weakening security of unupgraded nodes
22412237 // if we start doing this too early.
2242- assert (recentRejects);
2243- recentRejects->insert (porphanTx->GetWitnessHash ());
2238+ recentRejects.insert (porphanTx->GetWitnessHash ());
22442239 // If the transaction failed for TX_INPUTS_NOT_STANDARD,
22452240 // then we know that the witness was irrelevant to the policy
22462241 // failure, since this check depends only on the txid
@@ -2252,7 +2247,7 @@ void PeerManagerImpl::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
22522247 if (state.GetResult () == TxValidationResult::TX_INPUTS_NOT_STANDARD && porphanTx->GetWitnessHash () != porphanTx->GetHash ()) {
22532248 // We only add the txid if it differs from the wtxid, to
22542249 // avoid wasting entries in the rolling bloom filter.
2255- recentRejects-> insert (porphanTx->GetHash ());
2250+ recentRejects. insert (porphanTx->GetHash ());
22562251 }
22572252 }
22582253 m_orphanage.EraseTx (orphanHash);
@@ -3255,7 +3250,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
32553250 std::sort (unique_parents.begin (), unique_parents.end ());
32563251 unique_parents.erase (std::unique (unique_parents.begin (), unique_parents.end ()), unique_parents.end ());
32573252 for (const uint256& parent_txid : unique_parents) {
3258- if (recentRejects-> contains (parent_txid)) {
3253+ if (recentRejects. contains (parent_txid)) {
32593254 fRejectedParents = true ;
32603255 break ;
32613256 }
@@ -3296,8 +3291,8 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
32963291 // regardless of what witness is provided, we will not accept
32973292 // this, so we don't need to allow for redownload of this txid
32983293 // from any of our non-wtxidrelay peers.
3299- recentRejects-> insert (tx.GetHash ());
3300- recentRejects-> insert (tx.GetWitnessHash ());
3294+ recentRejects. insert (tx.GetHash ());
3295+ recentRejects. insert (tx.GetWitnessHash ());
33013296 m_txrequest.ForgetTxHash (tx.GetHash ());
33023297 m_txrequest.ForgetTxHash (tx.GetWitnessHash ());
33033298 }
@@ -3316,8 +3311,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
33163311 // See also comments in https://github.com/bitcoin/bitcoin/pull/18044#discussion_r443419034
33173312 // for concerns around weakening security of unupgraded nodes
33183313 // if we start doing this too early.
3319- assert (recentRejects);
3320- recentRejects->insert (tx.GetWitnessHash ());
3314+ recentRejects.insert (tx.GetWitnessHash ());
33213315 m_txrequest.ForgetTxHash (tx.GetWitnessHash ());
33223316 // If the transaction failed for TX_INPUTS_NOT_STANDARD,
33233317 // then we know that the witness was irrelevant to the policy
@@ -3328,7 +3322,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
33283322 // transactions are later received (resulting in
33293323 // parent-fetching by txid via the orphan-handling logic).
33303324 if (state.GetResult () == TxValidationResult::TX_INPUTS_NOT_STANDARD && tx.GetWitnessHash () != tx.GetHash ()) {
3331- recentRejects-> insert (tx.GetHash ());
3325+ recentRejects. insert (tx.GetHash ());
33323326 m_txrequest.ForgetTxHash (tx.GetHash ());
33333327 }
33343328 if (RecursiveDynamicUsage (*ptx) < 100000 ) {
0 commit comments