Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FreshEyes] locks: introduce mutex for tx download, flush rejection filters on UpdatedBlockTip #17

Open
wants to merge 7 commits into
base: bitcoin-fresheyes-staging-master-30111
Choose a base branch
from
Prev Previous commit
scripted-diff: rename TxOrphanage::EraseTxNoLock to EraseTxInternal
The lock doesn't exist anymore.

-BEGIN VERIFY SCRIPT-
sed -i 's/EraseTxNoLock/EraseTxInternal/g' src/txorphanage.*
-END VERIFY SCRIPT-))'
glozow committed May 20, 2024
commit 7c3fb97284dcf8cf78f5edda783bfa62846ab125
12 changes: 6 additions & 6 deletions src/txorphanage.cpp
Original file line number Diff line number Diff line change
@@ -52,10 +52,10 @@ bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer)

int TxOrphanage::EraseTx(const Wtxid& wtxid)
{
return EraseTxNoLock(wtxid);
return EraseTxInternal(wtxid);
}

int TxOrphanage::EraseTxNoLock(const Wtxid& wtxid)
int TxOrphanage::EraseTxInternal(const Wtxid& wtxid)
{
std::map<Wtxid, OrphanTx>::iterator it = m_orphans.find(wtxid);
if (it == m_orphans.end())
@@ -101,7 +101,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 += EraseTxInternal(wtxid);
}
}
if (nErased > 0) LogPrint(BCLog::TXPACKAGES, "Erased %d orphan transaction(s) from peer=%d\n", nErased, peer);
@@ -121,7 +121,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 += EraseTxInternal(maybeErase->second.tx->GetWitnessHash());
} else {
nMinExpTime = std::min(maybeErase->second.nTimeExpire, nMinExpTime);
}
@@ -134,7 +134,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());
EraseTxInternal(m_orphan_list[randompos]->second.tx->GetWitnessHash());
++nEvicted;
}
if (nEvicted > 0) LogPrint(BCLog::TXPACKAGES, "orphanage overflow, removed %u tx\n", nEvicted);
@@ -213,7 +213,7 @@ void TxOrphanage::EraseForBlock(const CBlock& block)
if (vOrphanErase.size()) {
int nErased = 0;
for (const auto& orphanHash : vOrphanErase) {
nErased += EraseTxNoLock(orphanHash);
nErased += EraseTxInternal(orphanHash);
}
LogPrint(BCLog::TXPACKAGES, "Erased %d orphan transaction(s) included or conflicted by block\n", nErased);
}
2 changes: 1 addition & 1 deletion src/txorphanage.h
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ class TxOrphanage {
std::vector<OrphanMap::iterator> m_orphan_list;

/** Erase an orphan by wtxid */
int EraseTxNoLock(const Wtxid& wtxid);
int EraseTxInternal(const Wtxid& wtxid);
};

#endif // BITCOIN_TXORPHANAGE_H