[txorphanage] account for weight of orphans

This commit is contained in:
glozow
2025-01-27 06:56:43 -05:00
parent 82ba505134
commit 59cd0f0e09
2 changed files with 17 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ bool TxOrphanage::AddTx(const CTransactionRef& tx, NodeId peer)
for (const CTxIn& txin : tx->vin) {
m_outpoint_to_orphan_it[txin.prevout].insert(ret.first);
}
m_total_orphan_usage += sz;
LogDebug(BCLog::TXPACKAGES, "stored orphan tx %s (wtxid=%s), weight: %u (mapsz %u outsz %u)\n", hash.ToString(), wtxid.ToString(), sz,
m_orphans.size(), m_outpoint_to_orphan_it.size());
@@ -77,6 +78,9 @@ int TxOrphanage::EraseTx(const Wtxid& wtxid)
m_outpoint_to_orphan_it.erase(itPrev);
}
const auto tx_size{it->second.GetUsage()};
m_total_orphan_usage -= tx_size;
size_t old_pos = it->second.list_pos;
assert(m_orphan_list[old_pos] == it);
if (old_pos + 1 != m_orphan_list.size()) {