Skip to content

Commit c85acce

Browse files
committed
[refactor] delete EraseTxNoLock, just use EraseTx
1 parent 6ff8406 commit c85acce

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/txorphanage.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer)
5252
}
5353

5454
int TxOrphanage::EraseTx(const Wtxid& wtxid)
55-
{
56-
return EraseTxNoLock(wtxid);
57-
}
58-
59-
int TxOrphanage::EraseTxNoLock(const Wtxid& wtxid)
6055
{
6156
std::map<Wtxid, OrphanTx>::iterator it = m_orphans.find(wtxid);
6257
if (it == m_orphans.end())
@@ -102,7 +97,7 @@ void TxOrphanage::EraseForPeer(NodeId peer)
10297
// increment to avoid iterator becoming invalid after erasure
10398
const auto& [wtxid, orphan] = *iter++;
10499
if (orphan.fromPeer == peer) {
105-
nErased += EraseTxNoLock(wtxid);
100+
nErased += EraseTx(wtxid);
106101
}
107102
}
108103
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)
121116
{
122117
std::map<Wtxid, OrphanTx>::iterator maybeErase = iter++;
123118
if (maybeErase->second.nTimeExpire <= nNow) {
124-
nErased += EraseTxNoLock(maybeErase->second.tx->GetWitnessHash());
119+
nErased += EraseTx(maybeErase->second.tx->GetWitnessHash());
125120
} else {
126121
nMinExpTime = std::min(maybeErase->second.nTimeExpire, nMinExpTime);
127122
}
@@ -134,7 +129,7 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans, FastRandomContext& rng)
134129
{
135130
// Evict a random orphan:
136131
size_t randompos = rng.randrange(m_orphan_list.size());
137-
EraseTxNoLock(m_orphan_list[randompos]->second.tx->GetWitnessHash());
132+
EraseTx(m_orphan_list[randompos]->second.tx->GetWitnessHash());
138133
++nEvicted;
139134
}
140135
if (nEvicted > 0) LogPrint(BCLog::TXPACKAGES, "orphanage overflow, removed %u tx\n", nEvicted);
@@ -213,7 +208,7 @@ void TxOrphanage::EraseForBlock(const CBlock& block)
213208
if (vOrphanErase.size()) {
214209
int nErased = 0;
215210
for (const auto& orphanHash : vOrphanErase) {
216-
nErased += EraseTxNoLock(orphanHash);
211+
nErased += EraseTx(orphanHash);
217212
}
218213
LogPrint(BCLog::TXPACKAGES, "Erased %d orphan transaction(s) included or conflicted by block\n", nErased);
219214
}

src/txorphanage.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,6 @@ class TxOrphanage {
9999
/** Orphan transactions in vector for quick random eviction */
100100
std::vector<OrphanMap::iterator> m_orphan_list;
101101

102-
/** Erase an orphan by wtxid */
103-
int EraseTxNoLock(const Wtxid& wtxid);
104-
105102
/** Timestamp for the next scheduled sweep of expired orphans */
106103
NodeSeconds m_next_sweep{0s};
107104
};

0 commit comments

Comments
 (0)