diff options
author | glozow <gloriajzhao@gmail.com> | 2024-05-23 13:25:41 +0100 |
---|---|---|
committer | glozow <gloriajzhao@gmail.com> | 2024-07-16 10:21:41 +0100 |
commit | c85accecafc20f6a6ae94bdf6cdd3ba9747218fd (patch) | |
tree | fe0ef67f863c89de7d5988e5c71f7d7e309fba61 /src | |
parent | 6ff84069a5dd92303ed2ec28f0ec7c96bbda3938 (diff) |
[refactor] delete EraseTxNoLock, just use EraseTx
Diffstat (limited to 'src')
-rw-r--r-- | src/txorphanage.cpp | 13 | ||||
-rw-r--r-- | src/txorphanage.h | 3 |
2 files changed, 4 insertions, 12 deletions
diff --git a/src/txorphanage.cpp b/src/txorphanage.cpp index 29f1c19c17..df9b96e64d 100644 --- a/src/txorphanage.cpp +++ b/src/txorphanage.cpp @@ -53,11 +53,6 @@ bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer) int TxOrphanage::EraseTx(const Wtxid& wtxid) { - return EraseTxNoLock(wtxid); -} - -int TxOrphanage::EraseTxNoLock(const Wtxid& wtxid) -{ std::map<Wtxid, OrphanTx>::iterator it = m_orphans.find(wtxid); if (it == m_orphans.end()) return 0; @@ -102,7 +97,7 @@ void TxOrphanage::EraseForPeer(NodeId peer) // increment to avoid iterator becoming invalid after erasure const auto& [wtxid, orphan] = *iter++; if (orphan.fromPeer == peer) { - nErased += EraseTxNoLock(wtxid); + nErased += EraseTx(wtxid); } } if (nErased > 0) LogPrint(BCLog::TXPACKAGES, "Erased %d orphan transaction(s) from peer=%d\n", nErased, peer); @@ -121,7 +116,7 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans, FastRandomContext& rng) { std::map<Wtxid, OrphanTx>::iterator maybeErase = iter++; if (maybeErase->second.nTimeExpire <= nNow) { - nErased += EraseTxNoLock(maybeErase->second.tx->GetWitnessHash()); + nErased += EraseTx(maybeErase->second.tx->GetWitnessHash()); } else { nMinExpTime = std::min(maybeErase->second.nTimeExpire, nMinExpTime); } @@ -134,7 +129,7 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans, FastRandomContext& rng) { // Evict a random orphan: size_t randompos = rng.randrange(m_orphan_list.size()); - EraseTxNoLock(m_orphan_list[randompos]->second.tx->GetWitnessHash()); + EraseTx(m_orphan_list[randompos]->second.tx->GetWitnessHash()); ++nEvicted; } if (nEvicted > 0) LogPrint(BCLog::TXPACKAGES, "orphanage overflow, removed %u tx\n", nEvicted); @@ -213,7 +208,7 @@ void TxOrphanage::EraseForBlock(const CBlock& block) if (vOrphanErase.size()) { int nErased = 0; for (const auto& orphanHash : vOrphanErase) { - nErased += EraseTxNoLock(orphanHash); + nErased += EraseTx(orphanHash); } LogPrint(BCLog::TXPACKAGES, "Erased %d orphan transaction(s) included or conflicted by block\n", nErased); } diff --git a/src/txorphanage.h b/src/txorphanage.h index 9917266749..207b79e009 100644 --- a/src/txorphanage.h +++ b/src/txorphanage.h @@ -99,9 +99,6 @@ protected: /** Orphan transactions in vector for quick random eviction */ std::vector<OrphanMap::iterator> m_orphan_list; - /** Erase an orphan by wtxid */ - int EraseTxNoLock(const Wtxid& wtxid); - /** Timestamp for the next scheduled sweep of expired orphans */ NodeSeconds m_next_sweep{0s}; }; |