@@ -470,7 +470,7 @@ class PeerManagerImpl final : public PeerManager
470
470
*
471
471
* Memory used: 1.3 MB
472
472
*/
473
- std::unique_ptr< CRollingBloomFilter> recentRejects GUARDED_BY (cs_main);
473
+ CRollingBloomFilter recentRejects GUARDED_BY (:: cs_main){ 120'000 , 0.000'001 } ;
474
474
uint256 hashRecentRejectsChainTip GUARDED_BY (cs_main);
475
475
476
476
/*
@@ -1396,9 +1396,6 @@ PeerManagerImpl::PeerManagerImpl(const CChainParams& chainparams, CConnman& conn
1396
1396
m_mempool(pool),
1397
1397
m_ignore_incoming_txs(ignore_incoming_txs)
1398
1398
{
1399
- // Initialize global variables that cannot be constructed at startup.
1400
- recentRejects.reset (new CRollingBloomFilter (120000 , 0.000001 ));
1401
-
1402
1399
// Blocks don't typically have more than 4000 transactions, so this should
1403
1400
// be at least six blocks (~1 hr) worth of transactions that we can store,
1404
1401
// inserting both a txid and wtxid for every observed transaction.
@@ -1601,14 +1598,13 @@ void PeerManagerImpl::BlockChecked(const CBlock& block, const BlockValidationSta
1601
1598
1602
1599
bool PeerManagerImpl::AlreadyHaveTx (const GenTxid& gtxid)
1603
1600
{
1604
- assert (recentRejects);
1605
1601
if (m_chainman.ActiveChain ().Tip ()->GetBlockHash () != hashRecentRejectsChainTip) {
1606
1602
// If the chain tip has changed previously rejected transactions
1607
1603
// might be now valid, e.g. due to a nLockTime'd tx becoming valid,
1608
1604
// or a double-spend. Reset the rejects filter and give those
1609
1605
// txs a second chance.
1610
1606
hashRecentRejectsChainTip = m_chainman.ActiveChain ().Tip ()->GetBlockHash ();
1611
- recentRejects-> reset ();
1607
+ recentRejects. reset ();
1612
1608
}
1613
1609
1614
1610
const uint256& hash = gtxid.GetHash ();
@@ -1620,7 +1616,7 @@ bool PeerManagerImpl::AlreadyHaveTx(const GenTxid& gtxid)
1620
1616
if (m_recent_confirmed_transactions->contains (hash)) return true ;
1621
1617
}
1622
1618
1623
- return recentRejects-> contains (hash) || m_mempool.exists (gtxid);
1619
+ return recentRejects. contains (hash) || m_mempool.exists (gtxid);
1624
1620
}
1625
1621
1626
1622
bool PeerManagerImpl::AlreadyHaveBlock (const uint256& block_hash)
@@ -2239,8 +2235,7 @@ void PeerManagerImpl::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
2239
2235
// See also comments in https://github.com/bitcoin/bitcoin/pull/18044#discussion_r443419034
2240
2236
// for concerns around weakening security of unupgraded nodes
2241
2237
// if we start doing this too early.
2242
- assert (recentRejects);
2243
- recentRejects->insert (porphanTx->GetWitnessHash ());
2238
+ recentRejects.insert (porphanTx->GetWitnessHash ());
2244
2239
// If the transaction failed for TX_INPUTS_NOT_STANDARD,
2245
2240
// then we know that the witness was irrelevant to the policy
2246
2241
// failure, since this check depends only on the txid
@@ -2252,7 +2247,7 @@ void PeerManagerImpl::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
2252
2247
if (state.GetResult () == TxValidationResult::TX_INPUTS_NOT_STANDARD && porphanTx->GetWitnessHash () != porphanTx->GetHash ()) {
2253
2248
// We only add the txid if it differs from the wtxid, to
2254
2249
// avoid wasting entries in the rolling bloom filter.
2255
- recentRejects-> insert (porphanTx->GetHash ());
2250
+ recentRejects. insert (porphanTx->GetHash ());
2256
2251
}
2257
2252
}
2258
2253
m_orphanage.EraseTx (orphanHash);
@@ -3255,7 +3250,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3255
3250
std::sort (unique_parents.begin (), unique_parents.end ());
3256
3251
unique_parents.erase (std::unique (unique_parents.begin (), unique_parents.end ()), unique_parents.end ());
3257
3252
for (const uint256& parent_txid : unique_parents) {
3258
- if (recentRejects-> contains (parent_txid)) {
3253
+ if (recentRejects. contains (parent_txid)) {
3259
3254
fRejectedParents = true ;
3260
3255
break ;
3261
3256
}
@@ -3296,8 +3291,8 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3296
3291
// regardless of what witness is provided, we will not accept
3297
3292
// this, so we don't need to allow for redownload of this txid
3298
3293
// 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 ());
3301
3296
m_txrequest.ForgetTxHash (tx.GetHash ());
3302
3297
m_txrequest.ForgetTxHash (tx.GetWitnessHash ());
3303
3298
}
@@ -3316,8 +3311,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3316
3311
// See also comments in https://github.com/bitcoin/bitcoin/pull/18044#discussion_r443419034
3317
3312
// for concerns around weakening security of unupgraded nodes
3318
3313
// if we start doing this too early.
3319
- assert (recentRejects);
3320
- recentRejects->insert (tx.GetWitnessHash ());
3314
+ recentRejects.insert (tx.GetWitnessHash ());
3321
3315
m_txrequest.ForgetTxHash (tx.GetWitnessHash ());
3322
3316
// If the transaction failed for TX_INPUTS_NOT_STANDARD,
3323
3317
// 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,
3328
3322
// transactions are later received (resulting in
3329
3323
// parent-fetching by txid via the orphan-handling logic).
3330
3324
if (state.GetResult () == TxValidationResult::TX_INPUTS_NOT_STANDARD && tx.GetWitnessHash () != tx.GetHash ()) {
3331
- recentRejects-> insert (tx.GetHash ());
3325
+ recentRejects. insert (tx.GetHash ());
3332
3326
m_txrequest.ForgetTxHash (tx.GetHash ());
3333
3327
}
3334
3328
if (RecursiveDynamicUsage (*ptx) < 100000 ) {
0 commit comments