aboutsummaryrefslogtreecommitdiff
path: root/src/txmempool.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-04-06 09:46:08 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2015-04-06 09:48:17 +0200
commit27e8d224e9d7577a2c25a26eb5e40ed0b25a6280 (patch)
treeb4c6305406e57d378cd60e93f19a1f08bb2f9772 /src/txmempool.cpp
parent2dc679d22f821d26a9f8a7eef6d095ef21d1b27c (diff)
parentad9e86dca11dce023d827d342e966f3806c39d27 (diff)
Merge pull request #5945
ad9e86d Keep mempool consistent during block-reorgs (Gavin Andresen)
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r--src/txmempool.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 0d50660327..85ea3f77b5 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -444,6 +444,18 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list<CTransaction>& rem
LOCK(cs);
std::deque<uint256> txToRemove;
txToRemove.push_back(origTx.GetHash());
+ if (fRecursive && !mapTx.count(origTx.GetHash())) {
+ // If recursively removing but origTx isn't in the mempool
+ // be sure to remove any children that are in the pool. This can
+ // happen during chain re-orgs if origTx isn't re-accepted into
+ // the mempool for any reason.
+ for (unsigned int i = 0; i < origTx.vout.size(); i++) {
+ std::map<COutPoint, CInPoint>::iterator it = mapNextTx.find(COutPoint(origTx.GetHash(), i));
+ if (it == mapNextTx.end())
+ continue;
+ txToRemove.push_back(it->second.ptx->GetHash());
+ }
+ }
while (!txToRemove.empty())
{
uint256 hash = txToRemove.front();