From 71b27467bd5d16b774a8fbcc8c5650458bba9615 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Fri, 2 Aug 2013 02:47:22 +0200 Subject: [PATCH] Fix non-standard disconnected transactions causing mempool orphans Conflicts: src/main.cpp --- src/main.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7f0515118..fc5a2e06c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -845,15 +845,15 @@ bool CTxMemPool::remove(const CTransaction &tx, bool fRecursive) { LOCK(cs); uint256 hash = tx.GetHash(); + if (fRecursive) { + for (unsigned int i = 0; i < tx.vout.size(); i++) { + std::map::iterator it = mapNextTx.find(COutPoint(hash, i)); + if (it != mapNextTx.end()) + remove(*it->second.ptx, true); + } + } if (mapTx.count(hash)) { - if (fRecursive) { - for (unsigned int i = 0; i < tx.vout.size(); i++) { - std::map::iterator it = mapNextTx.find(COutPoint(hash, i)); - if (it != mapNextTx.end()) - remove(*it->second.ptx, true); - } - } BOOST_FOREACH(const CTxIn& txin, tx.vin) mapNextTx.erase(txin.prevout); mapTx.erase(hash); @@ -1865,7 +1865,8 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew) BOOST_FOREACH(CTransaction& tx, vResurrect) { // ignore validation errors in resurrected transactions CValidationState stateDummy; - tx.AcceptToMemoryPool(stateDummy, true, false); + if (!tx.AcceptToMemoryPool(stateDummy, true, false)) + mempool.remove(tx, true); } // Delete redundant memory transactions that are in the connected branch