@@ -489,6 +489,8 @@ class PeerManagerImpl final : public PeerManager
489
489
CTxMemPool& pool, node::Warnings& warnings, Options opts);
490
490
491
491
/* * Overridden from CValidationInterface. */
492
+ void ActiveTipChange (const CBlockIndex* new_tip, bool ) override
493
+ EXCLUSIVE_LOCKS_REQUIRED(!m_recent_confirmed_transactions_mutex, !m_tx_download_mutex);
492
494
void BlockConnected (ChainstateRole role, const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override
493
495
EXCLUSIVE_LOCKS_REQUIRED(!m_recent_confirmed_transactions_mutex, !m_tx_download_mutex);
494
496
void BlockDisconnected (const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex) override
@@ -2074,6 +2076,22 @@ void PeerManagerImpl::StartScheduledTasks(CScheduler& scheduler)
2074
2076
scheduler.scheduleFromNow ([&] { ReattemptInitialBroadcast (scheduler); }, delta);
2075
2077
}
2076
2078
2079
+ void PeerManagerImpl::ActiveTipChange (const CBlockIndex* new_tip, bool is_ibd)
2080
+ {
2081
+ AssertLockNotHeld (m_mempool.cs );
2082
+ AssertLockNotHeld (m_tx_download_mutex);
2083
+
2084
+ if (!is_ibd) {
2085
+ LOCK (m_tx_download_mutex);
2086
+ // If the chain tip has changed, previously rejected transactions might now be valid, e.g. due
2087
+ // to a timelock. Reset the rejection filters to give those transactions another chance if we
2088
+ // see them again.
2089
+ m_recent_rejects.reset ();
2090
+ m_recent_rejects_reconsiderable.reset ();
2091
+ hashRecentRejectsChainTip = new_tip->GetBlockHash ();
2092
+ }
2093
+ }
2094
+
2077
2095
/* *
2078
2096
* Evict orphan txn pool entries based on a newly connected
2079
2097
* block, remember the recently confirmed transactions, and delete tracked
@@ -2277,7 +2295,11 @@ bool PeerManagerImpl::AlreadyHaveTx(const GenTxid& gtxid, bool include_reconside
2277
2295
AssertLockHeld (::cs_main);
2278
2296
AssertLockHeld (m_tx_download_mutex);
2279
2297
2280
- if (m_chainman.ActiveChain ().Tip ()->GetBlockHash () != hashRecentRejectsChainTip) {
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 ())) {
2281
2303
// If the chain tip has changed previously rejected transactions
2282
2304
// might be now valid, e.g. due to a nLockTime'd tx becoming valid,
2283
2305
// or a double-spend. Reset the rejects filter and give those
0 commit comments