Skip to content

Commit 723ea0f

Browse files
committed
remove obsoleted hashRecentRejectsChainTip
This also means AlreadyHaveTx no longer needs cs_main held.
1 parent 18a4355 commit 723ea0f

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -861,11 +861,9 @@ class PeerManagerImpl final : public PeerManager
861861
* - m_recent_rejects
862862
* - m_recent_rejects_reconsiderable (if include_reconsiderable = true)
863863
* - m_recent_confirmed_transactions
864-
* Also responsible for resetting m_recent_rejects and m_recent_rejects_reconsiderable if the
865-
* chain tip has changed.
866864
* */
867865
bool AlreadyHaveTx(const GenTxid& gtxid, bool include_reconsiderable)
868-
EXCLUSIVE_LOCKS_REQUIRED(cs_main, !m_recent_confirmed_transactions_mutex, m_tx_download_mutex);
866+
EXCLUSIVE_LOCKS_REQUIRED(!m_recent_confirmed_transactions_mutex, m_tx_download_mutex);
869867

870868
/**
871869
* Filter for transactions that were recently rejected by the mempool.
@@ -902,9 +900,6 @@ class PeerManagerImpl final : public PeerManager
902900
* Memory used: 1.3 MB
903901
*/
904902
CRollingBloomFilter m_recent_rejects GUARDED_BY(m_tx_download_mutex){120'000, 0.000'001};
905-
/** Block hash of chain tip the last time we reset m_recent_rejects and
906-
* m_recent_rejects_reconsiderable. */
907-
uint256 hashRecentRejectsChainTip GUARDED_BY(m_tx_download_mutex);
908903

909904
/**
910905
* Filter for:
@@ -2088,7 +2083,6 @@ void PeerManagerImpl::ActiveTipChange(const CBlockIndex* new_tip, bool is_ibd)
20882083
// see them again.
20892084
m_recent_rejects.reset();
20902085
m_recent_rejects_reconsiderable.reset();
2091-
hashRecentRejectsChainTip = new_tip->GetBlockHash();
20922086
}
20932087
}
20942088

@@ -2292,23 +2286,8 @@ void PeerManagerImpl::BlockChecked(const CBlock& block, const BlockValidationSta
22922286

22932287
bool PeerManagerImpl::AlreadyHaveTx(const GenTxid& gtxid, bool include_reconsiderable)
22942288
{
2295-
AssertLockHeld(::cs_main);
22962289
AssertLockHeld(m_tx_download_mutex);
22972290

2298-
// Since recent_rejects is updated whenever the tip changes, and hashRecentRejectsChainTip is
2299-
// not set until the first time it is called outside of IBD, hashRecentRejectsChainTip should
2300-
// always be up to date with the current chain tip.
2301-
if (!Assume(hashRecentRejectsChainTip == uint256::ZERO ||
2302-
hashRecentRejectsChainTip == m_chainman.ActiveChain().Tip()->GetBlockHash())) {
2303-
// If the chain tip has changed previously rejected transactions
2304-
// might be now valid, e.g. due to a nLockTime'd tx becoming valid,
2305-
// or a double-spend. Reset the rejects filter and give those
2306-
// txs a second chance.
2307-
hashRecentRejectsChainTip = m_chainman.ActiveChain().Tip()->GetBlockHash();
2308-
m_recent_rejects.reset();
2309-
m_recent_rejects_reconsiderable.reset();
2310-
}
2311-
23122291
const uint256& hash = gtxid.GetHash();
23132292

23142293
if (gtxid.IsWtxid()) {

0 commit comments

Comments
 (0)