aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-12-02 10:12:19 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2015-12-02 10:17:43 +0100
commitbdda4d567eedd44d3088980fa47ab03827103f68 (patch)
tree085c3f0ff182276ba87cc9eb1c2b8713ba503231 /src/txmempool.cpp
parent4a63f946760666adcb1a4dde26fc7c6d31c301af (diff)
parentdd5862c4cdc02535948042fe519694166bcd2bb7 (diff)
downloadbitcoin-bdda4d567eedd44d3088980fa47ab03827103f68.tar.xz
Merge pull request #6872
dd5862c Flush coins cache also after transaction processing (Pieter Wuille) bde953e Uncache input txn in utxo cache if a tx is not accepted to mempool (Matt Corallo) 97bf377 Add CCoinsViewCache::HaveCoinsInCache to check if a tx is cached (Matt Corallo) 677aa3d Discard txn cache entries that were loaded for removed mempool txn (Matt Corallo) b2e74bd Get the set of now-uncacheable-txn from CTxMemPool::TrimToSize (Matt Corallo) 74d0f90 Add method to remove a tx from CCoinsViewCache if it is unchanged (Matt Corallo)
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 35be216287..fea5da8029 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))