mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
Add Mempool Expire function to remove old transactions
(note the 9x multiplier on (void*)'s for CTxMemPool::DynamicMemoryUsage
was accidentally introduced in 5add7a7 but should have waited for this
commit which adds the extra index)
This commit is contained in:
committed by
Matt Corallo
parent
78b82f4a16
commit
49b6fd5663
@@ -792,6 +792,22 @@ void CTxMemPool::RemoveStaged(setEntries &stage) {
|
||||
}
|
||||
}
|
||||
|
||||
int CTxMemPool::Expire(int64_t time) {
|
||||
LOCK(cs);
|
||||
indexed_transaction_set::nth_index<2>::type::iterator it = mapTx.get<2>().begin();
|
||||
setEntries toremove;
|
||||
while (it != mapTx.get<2>().end() && it->GetTime() < time) {
|
||||
toremove.insert(mapTx.project<0>(it));
|
||||
it++;
|
||||
}
|
||||
setEntries stage;
|
||||
BOOST_FOREACH(txiter removeit, toremove) {
|
||||
CalculateDescendants(removeit, stage);
|
||||
}
|
||||
RemoveStaged(stage);
|
||||
return stage.size();
|
||||
}
|
||||
|
||||
bool CTxMemPool::addUnchecked(const uint256&hash, const CTxMemPoolEntry &entry, bool fCurrentEstimate)
|
||||
{
|
||||
LOCK(cs);
|
||||
|
||||
Reference in New Issue
Block a user