aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.cpp
diff options
context:
space:
mode:
authorMatt Corallo <[email protected]>2015-10-21 17:44:00 -0700
committerMatt Corallo <[email protected]>2015-12-01 15:50:39 -0800
commitb2e74bd292460ca00fefc6356594318307365397 (patch)
treee7a0f8fbf7f9e9b33a72f6f2bd5e74cfe8831d41 /src/txmempool.cpp
parentAdd method to remove a tx from CCoinsViewCache if it is unchanged (diff)
downloaddiscoin-b2e74bd292460ca00fefc6356594318307365397.tar.xz
discoin-b2e74bd292460ca00fefc6356594318307365397.zip
Get the set of now-uncacheable-txn from CTxMemPool::TrimToSize
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r--src/txmempool.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 35be21628..fea5da802 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -944,7 +944,7 @@ void CTxMemPool::trackPackageRemoved(const CFeeRate& rate) {
}
}
-void CTxMemPool::TrimToSize(size_t sizelimit) {
+void CTxMemPool::TrimToSize(size_t sizelimit, std::vector<uint256>* pvNoSpendsRemaining) {
LOCK(cs);
unsigned nTxnRemoved = 0;
@@ -963,8 +963,26 @@ void CTxMemPool::TrimToSize(size_t sizelimit) {
setEntries stage;
CalculateDescendants(mapTx.project<0>(it), stage);
- RemoveStaged(stage);
nTxnRemoved += stage.size();
+
+ std::vector<CTransaction> txn;
+ if (pvNoSpendsRemaining) {
+ txn.reserve(stage.size());
+ BOOST_FOREACH(txiter it, stage)
+ txn.push_back(it->GetTx());
+ }
+ RemoveStaged(stage);
+ if (pvNoSpendsRemaining) {
+ BOOST_FOREACH(const CTransaction& tx, txn) {
+ BOOST_FOREACH(const CTxIn& txin, tx.vin) {
+ if (exists(txin.prevout.hash))
+ continue;
+ std::map<COutPoint, CInPoint>::iterator it = mapNextTx.lower_bound(COutPoint(txin.prevout.hash, 0));
+ if (it == mapNextTx.end() || it->first.hash != txin.prevout.hash)
+ pvNoSpendsRemaining->push_back(txin.prevout.hash);
+ }
+ }
+ }
}
if (maxFeeRateRemoved > CFeeRate(0))