[prep/test] have TxOrphanage remember its own limits in LimitOrphans

Move towards a model where TxOrphanage is initialized with limits that
it remembers throughout its lifetime.
Remove the param. Limiting by number of unique orphans will be removed
in a later commit.
Now that -maxorphantx is gone, this does not change the node behavior.
The parameter is only used in tests.
This commit is contained in:
glozow
2025-05-16 10:36:05 -04:00
parent d0af4239b7
commit 77ebe8f280
10 changed files with 19 additions and 36 deletions

View File

@@ -141,7 +141,7 @@ void TxOrphanage::EraseForPeer(NodeId peer)
if (nErased > 0) LogDebug(BCLog::TXPACKAGES, "Erased %d orphan transaction(s) from peer=%d\n", nErased, peer);
}
void TxOrphanage::LimitOrphans(unsigned int max_orphans, FastRandomContext& rng)
void TxOrphanage::LimitOrphans(FastRandomContext& rng)
{
unsigned int nEvicted = 0;
auto nNow{Now<NodeSeconds>()};
@@ -163,7 +163,7 @@ void TxOrphanage::LimitOrphans(unsigned int max_orphans, FastRandomContext& rng)
m_next_sweep = nMinExpTime + ORPHAN_TX_EXPIRE_INTERVAL;
if (nErased > 0) LogDebug(BCLog::TXPACKAGES, "Erased %d orphan tx due to expiration\n", nErased);
}
while (m_orphans.size() > max_orphans)
while (m_orphans.size() > DEFAULT_MAX_ORPHAN_TRANSACTIONS)
{
// Evict a random orphan:
size_t randompos = rng.randrange(m_orphan_list.size());