[refactor] delete EraseTxNoLock, just use EraseTx
This commit is contained in:
1 parent
6ff84069a5
commit
c85accecaf
2 files changed
+4
-12
No files matched your search
+4
-9
@@ -52,11 +52,6 @@ bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int TxOrphanage::EraseTx(const Wtxid& wtxid)
|
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);
|
std::map<Wtxid, OrphanTx>::iterator it = m_orphans.find(wtxid);
|
||||||
if (it == m_orphans.end())
|
if (it == m_orphans.end())
|
||||||
@@ -102,7 +97,7 @@ void TxOrphanage::EraseForPeer(NodeId peer)
|
|||||||
// increment to avoid iterator becoming invalid after erasure
|
// increment to avoid iterator becoming invalid after erasure
|
||||||
const auto& [wtxid, orphan] = *iter++;
|
const auto& [wtxid, orphan] = *iter++;
|
||||||
if (orphan.fromPeer == peer) {
|
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);
|
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++;
|
std::map<Wtxid, OrphanTx>::iterator maybeErase = iter++;
|
||||||
if (maybeErase->second.nTimeExpire <= nNow) {
|
if (maybeErase->second.nTimeExpire <= nNow) {
|
||||||
nErased += EraseTxNoLock(maybeErase->second.tx->GetWitnessHash());
|
nErased += EraseTx(maybeErase->second.tx->GetWitnessHash());
|
||||||
} else {
|
} else {
|
||||||
nMinExpTime = std::min(maybeErase->second.nTimeExpire, nMinExpTime);
|
nMinExpTime = std::min(maybeErase->second.nTimeExpire, nMinExpTime);
|
||||||
}
|
}
|
||||||
@@ -134,7 +129,7 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans, FastRandomContext& rng)
|
|||||||
{
|
{
|
||||||
// Evict a random orphan:
|
// Evict a random orphan:
|
||||||
size_t randompos = rng.randrange(m_orphan_list.size());
|
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;
|
++nEvicted;
|
||||||
}
|
}
|
||||||
if (nEvicted > 0) LogPrint(BCLog::TXPACKAGES, "orphanage overflow, removed %u tx\n", 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()) {
|
if (vOrphanErase.size()) {
|
||||||
int nErased = 0;
|
int nErased = 0;
|
||||||
for (const auto& orphanHash : vOrphanErase) {
|
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);
|
LogPrint(BCLog::TXPACKAGES, "Erased %d orphan transaction(s) included or conflicted by block\n", nErased);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,9 +99,6 @@ protected:
|
|||||||
/** Orphan transactions in vector for quick random eviction */
|
/** Orphan transactions in vector for quick random eviction */
|
||||||
std::vector<OrphanMap::iterator> m_orphan_list;
|
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 */
|
/** Timestamp for the next scheduled sweep of expired orphans */
|
||||||
NodeSeconds m_next_sweep{0s};
|
NodeSeconds m_next_sweep{0s};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user