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:
Pieter Wuille
2015-10-02 14:43:30 -07:00
committed by Matt Corallo
parent 78b82f4a16
commit 49b6fd5663
4 changed files with 29 additions and 1 deletions

View File

@@ -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);