mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-09 12:12:41 +01:00
lock m_recent_confirmed_transactions using m_tx_download_mutex
This commit is contained in:
@@ -490,11 +490,11 @@ public:
|
|||||||
|
|
||||||
/** Overridden from CValidationInterface. */
|
/** Overridden from CValidationInterface. */
|
||||||
void ActiveTipChange(const CBlockIndex* new_tip, bool) override
|
void ActiveTipChange(const CBlockIndex* new_tip, bool) override
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!m_recent_confirmed_transactions_mutex, !m_tx_download_mutex);
|
EXCLUSIVE_LOCKS_REQUIRED(!m_tx_download_mutex);
|
||||||
void BlockConnected(ChainstateRole role, const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override
|
void BlockConnected(ChainstateRole role, const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!m_recent_confirmed_transactions_mutex, !m_tx_download_mutex);
|
EXCLUSIVE_LOCKS_REQUIRED(!m_tx_download_mutex);
|
||||||
void BlockDisconnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex) override
|
void BlockDisconnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex) override
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!m_recent_confirmed_transactions_mutex, !m_tx_download_mutex);
|
EXCLUSIVE_LOCKS_REQUIRED(!m_tx_download_mutex);
|
||||||
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override
|
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
|
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
|
||||||
void BlockChecked(const CBlock& block, const BlockValidationState& state) override
|
void BlockChecked(const CBlock& block, const BlockValidationState& state) override
|
||||||
@@ -507,9 +507,9 @@ public:
|
|||||||
void FinalizeNode(const CNode& node) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_headers_presync_mutex, !m_tx_download_mutex);
|
void FinalizeNode(const CNode& node) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_headers_presync_mutex, !m_tx_download_mutex);
|
||||||
bool HasAllDesirableServiceFlags(ServiceFlags services) const override;
|
bool HasAllDesirableServiceFlags(ServiceFlags services) const override;
|
||||||
bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt) override
|
bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt) override
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_recent_confirmed_transactions_mutex, !m_most_recent_block_mutex, !m_headers_presync_mutex, g_msgproc_mutex, !m_tx_download_mutex);
|
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_most_recent_block_mutex, !m_headers_presync_mutex, g_msgproc_mutex, !m_tx_download_mutex);
|
||||||
bool SendMessages(CNode* pto) override
|
bool SendMessages(CNode* pto) override
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_recent_confirmed_transactions_mutex, !m_most_recent_block_mutex, g_msgproc_mutex, !m_tx_download_mutex);
|
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_most_recent_block_mutex, g_msgproc_mutex, !m_tx_download_mutex);
|
||||||
|
|
||||||
/** Implement PeerManager */
|
/** Implement PeerManager */
|
||||||
void StartScheduledTasks(CScheduler& scheduler) override;
|
void StartScheduledTasks(CScheduler& scheduler) override;
|
||||||
@@ -528,7 +528,7 @@ public:
|
|||||||
void UnitTestMisbehaving(NodeId peer_id) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex) { Misbehaving(*Assert(GetPeerRef(peer_id)), ""); };
|
void UnitTestMisbehaving(NodeId peer_id) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex) { Misbehaving(*Assert(GetPeerRef(peer_id)), ""); };
|
||||||
void ProcessMessage(CNode& pfrom, const std::string& msg_type, DataStream& vRecv,
|
void ProcessMessage(CNode& pfrom, const std::string& msg_type, DataStream& vRecv,
|
||||||
const std::chrono::microseconds time_received, const std::atomic<bool>& interruptMsgProc) override
|
const std::chrono::microseconds time_received, const std::atomic<bool>& interruptMsgProc) override
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_recent_confirmed_transactions_mutex, !m_most_recent_block_mutex, !m_headers_presync_mutex, g_msgproc_mutex, !m_tx_download_mutex);
|
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_most_recent_block_mutex, !m_headers_presync_mutex, g_msgproc_mutex, !m_tx_download_mutex);
|
||||||
void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds) override;
|
void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds) override;
|
||||||
ServiceFlags GetDesirableServiceFlags(ServiceFlags services) const override;
|
ServiceFlags GetDesirableServiceFlags(ServiceFlags services) const override;
|
||||||
|
|
||||||
@@ -863,7 +863,7 @@ private:
|
|||||||
* - m_recent_confirmed_transactions
|
* - m_recent_confirmed_transactions
|
||||||
* */
|
* */
|
||||||
bool AlreadyHaveTx(const GenTxid& gtxid, bool include_reconsiderable)
|
bool AlreadyHaveTx(const GenTxid& gtxid, bool include_reconsiderable)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(!m_recent_confirmed_transactions_mutex, m_tx_download_mutex);
|
EXCLUSIVE_LOCKS_REQUIRED(m_tx_download_mutex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter for transactions that were recently rejected by the mempool.
|
* Filter for transactions that were recently rejected by the mempool.
|
||||||
@@ -938,8 +938,7 @@ private:
|
|||||||
* transaction per day that would be inadvertently ignored (which is the
|
* transaction per day that would be inadvertently ignored (which is the
|
||||||
* same probability that we have in the reject filter).
|
* same probability that we have in the reject filter).
|
||||||
*/
|
*/
|
||||||
Mutex m_recent_confirmed_transactions_mutex;
|
CRollingBloomFilter m_recent_confirmed_transactions GUARDED_BY(m_tx_download_mutex){48'000, 0.000'001};
|
||||||
CRollingBloomFilter m_recent_confirmed_transactions GUARDED_BY(m_recent_confirmed_transactions_mutex){48'000, 0.000'001};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For sending `inv`s to inbound peers, we use a single (exponentially
|
* For sending `inv`s to inbound peers, we use a single (exponentially
|
||||||
@@ -2119,21 +2118,16 @@ void PeerManagerImpl::BlockConnected(
|
|||||||
LOCK(m_tx_download_mutex);
|
LOCK(m_tx_download_mutex);
|
||||||
m_orphanage.EraseForBlock(*pblock);
|
m_orphanage.EraseForBlock(*pblock);
|
||||||
|
|
||||||
{
|
|
||||||
LOCK(m_recent_confirmed_transactions_mutex);
|
|
||||||
for (const auto& ptx : pblock->vtx) {
|
for (const auto& ptx : pblock->vtx) {
|
||||||
m_recent_confirmed_transactions.insert(ptx->GetHash().ToUint256());
|
m_recent_confirmed_transactions.insert(ptx->GetHash().ToUint256());
|
||||||
if (ptx->HasWitness()) {
|
if (ptx->HasWitness()) {
|
||||||
m_recent_confirmed_transactions.insert(ptx->GetWitnessHash().ToUint256());
|
m_recent_confirmed_transactions.insert(ptx->GetWitnessHash().ToUint256());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
{
|
|
||||||
for (const auto& ptx : pblock->vtx) {
|
for (const auto& ptx : pblock->vtx) {
|
||||||
m_txrequest.ForgetTxHash(ptx->GetHash());
|
m_txrequest.ForgetTxHash(ptx->GetHash());
|
||||||
m_txrequest.ForgetTxHash(ptx->GetWitnessHash());
|
m_txrequest.ForgetTxHash(ptx->GetWitnessHash());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerManagerImpl::BlockDisconnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex)
|
void PeerManagerImpl::BlockDisconnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex)
|
||||||
@@ -2146,7 +2140,7 @@ void PeerManagerImpl::BlockDisconnected(const std::shared_ptr<const CBlock> &blo
|
|||||||
// block's worth of transactions in it, but that should be fine, since
|
// block's worth of transactions in it, but that should be fine, since
|
||||||
// presumably the most common case of relaying a confirmed transaction
|
// presumably the most common case of relaying a confirmed transaction
|
||||||
// should be just after a new block containing it is found.
|
// should be just after a new block containing it is found.
|
||||||
LOCK(m_recent_confirmed_transactions_mutex);
|
LOCK(m_tx_download_mutex);
|
||||||
m_recent_confirmed_transactions.reset();
|
m_recent_confirmed_transactions.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2310,10 +2304,7 @@ bool PeerManagerImpl::AlreadyHaveTx(const GenTxid& gtxid, bool include_reconside
|
|||||||
|
|
||||||
if (include_reconsiderable && m_recent_rejects_reconsiderable.contains(hash)) return true;
|
if (include_reconsiderable && m_recent_rejects_reconsiderable.contains(hash)) return true;
|
||||||
|
|
||||||
{
|
|
||||||
LOCK(m_recent_confirmed_transactions_mutex);
|
|
||||||
if (m_recent_confirmed_transactions.contains(hash)) return true;
|
if (m_recent_confirmed_transactions.contains(hash)) return true;
|
||||||
}
|
|
||||||
|
|
||||||
return m_recent_rejects.contains(hash) || m_mempool.exists(gtxid);
|
return m_recent_rejects.contains(hash) || m_mempool.exists(gtxid);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user