diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2015-10-02 14:43:30 -0700 |
---|---|---|
committer | Matt Corallo <git@bluematt.me> | 2015-10-13 00:44:03 -0700 |
commit | 49b6fd5663dfe081d127cd1eb11407c4d3eaf93d (patch) | |
tree | 30caec98dd3dc4fae4aef494ff04b0df81778ca4 /src/txmempool.cpp | |
parent | 78b82f4a16d8aad15ef397b1a1cd075b2efc8c16 (diff) |
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)
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r-- | src/txmempool.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
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); |