diff options
author | Anthony Towns <aj@erisian.com.au> | 2022-10-07 14:32:19 +1000 |
---|---|---|
committer | Anthony Towns <aj@erisian.com.au> | 2022-10-11 23:35:37 +1000 |
commit | 7082ce3e88d77456d60a5a66bd38807fbd66f311 (patch) | |
tree | 37777ad15de0baacd63d1fa4a9272481a7086307 /src/txorphanage.cpp | |
parent | 733d85f79cde353d8c9b54370f296b1031fa33d9 (diff) |
scripted-diff: rename and de-globalise g_cs_orphans
-BEGIN VERIFY SCRIPT-
sed -i -e 's/static RecursiveMutex/mutable Mutex/' src/txorphanage.h
sed -i -e '/RecursiveMutex/d' src/txorphanage.cpp
sed -i -e 's/g_cs_orphans/m_mutex/g' $(git grep -l g_cs_orphans src/)
-END VERIFY SCRIPT-
Diffstat (limited to 'src/txorphanage.cpp')
-rw-r--r-- | src/txorphanage.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/txorphanage.cpp b/src/txorphanage.cpp index bdebfc161f..b0b71e135c 100644 --- a/src/txorphanage.cpp +++ b/src/txorphanage.cpp @@ -15,11 +15,10 @@ static constexpr int64_t ORPHAN_TX_EXPIRE_TIME = 20 * 60; /** Minimum time between orphan transactions expire time checks in seconds */ static constexpr int64_t ORPHAN_TX_EXPIRE_INTERVAL = 5 * 60; -RecursiveMutex TxOrphanage::g_cs_orphans; bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer) { - LOCK(g_cs_orphans); + LOCK(m_mutex); const uint256& hash = tx->GetHash(); if (m_orphans.count(hash)) @@ -55,13 +54,13 @@ bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer) int TxOrphanage::EraseTx(const uint256& txid) { - LOCK(g_cs_orphans); + LOCK(m_mutex); return _EraseTx(txid); } int TxOrphanage::_EraseTx(const uint256& txid) { - AssertLockHeld(g_cs_orphans); + AssertLockHeld(m_mutex); std::map<uint256, OrphanTx>::iterator it = m_orphans.find(txid); if (it == m_orphans.end()) return 0; @@ -93,7 +92,7 @@ int TxOrphanage::_EraseTx(const uint256& txid) void TxOrphanage::EraseForPeer(NodeId peer) { - LOCK(g_cs_orphans); + LOCK(m_mutex); m_peer_work_set.erase(peer); @@ -112,7 +111,7 @@ void TxOrphanage::EraseForPeer(NodeId peer) void TxOrphanage::LimitOrphans(unsigned int max_orphans) { - LOCK(g_cs_orphans); + LOCK(m_mutex); unsigned int nEvicted = 0; static int64_t nNextSweep; @@ -148,7 +147,7 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans) void TxOrphanage::AddChildrenToWorkSet(const CTransaction& tx, NodeId peer) { - LOCK(g_cs_orphans); + LOCK(m_mutex); // Get this peer's work set, emplacing an empty set it didn't exist std::set<uint256>& orphan_work_set = m_peer_work_set.try_emplace(peer).first->second; @@ -165,7 +164,7 @@ void TxOrphanage::AddChildrenToWorkSet(const CTransaction& tx, NodeId peer) bool TxOrphanage::HaveTx(const GenTxid& gtxid) const { - LOCK(g_cs_orphans); + LOCK(m_mutex); if (gtxid.IsWtxid()) { return m_wtxid_to_orphan_it.count(gtxid.GetHash()); } else { @@ -175,7 +174,7 @@ bool TxOrphanage::HaveTx(const GenTxid& gtxid) const CTransactionRef TxOrphanage::GetTxToReconsider(NodeId peer, NodeId& originator, bool& more) { - LOCK(g_cs_orphans); + LOCK(m_mutex); auto work_set_it = m_peer_work_set.find(peer); if (work_set_it != m_peer_work_set.end()) { @@ -198,7 +197,7 @@ CTransactionRef TxOrphanage::GetTxToReconsider(NodeId peer, NodeId& originator, void TxOrphanage::EraseForBlock(const CBlock& block) { - LOCK(g_cs_orphans); + LOCK(m_mutex); std::vector<uint256> vOrphanErase; |