From 49b6fd5663dfe081d127cd1eb11407c4d3eaf93d Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Fri, 2 Oct 2015 14:43:30 -0700 Subject: 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) --- src/txmempool.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/txmempool.cpp') diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 1370cab0c0..57bb284602 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -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); -- cgit v1.2.3