Browse Source

Fix non-standard disconnected transactions causing mempool orphans

Conflicts:
	src/main.cpp
0.8
Pieter Wuille 11 years ago committed by Warren Togami
parent
commit
71b27467bd
  1. 7
      src/main.cpp

7
src/main.cpp

@ -845,8 +845,6 @@ bool CTxMemPool::remove(const CTransaction &tx, bool fRecursive)
{ {
LOCK(cs); LOCK(cs);
uint256 hash = tx.GetHash(); uint256 hash = tx.GetHash();
if (mapTx.count(hash))
{
if (fRecursive) { if (fRecursive) {
for (unsigned int i = 0; i < tx.vout.size(); i++) { for (unsigned int i = 0; i < tx.vout.size(); i++) {
std::map<COutPoint, CInPoint>::iterator it = mapNextTx.find(COutPoint(hash, i)); std::map<COutPoint, CInPoint>::iterator it = mapNextTx.find(COutPoint(hash, i));
@ -854,6 +852,8 @@ bool CTxMemPool::remove(const CTransaction &tx, bool fRecursive)
remove(*it->second.ptx, true); remove(*it->second.ptx, true);
} }
} }
if (mapTx.count(hash))
{
BOOST_FOREACH(const CTxIn& txin, tx.vin) BOOST_FOREACH(const CTxIn& txin, tx.vin)
mapNextTx.erase(txin.prevout); mapNextTx.erase(txin.prevout);
mapTx.erase(hash); mapTx.erase(hash);
@ -1865,7 +1865,8 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
BOOST_FOREACH(CTransaction& tx, vResurrect) { BOOST_FOREACH(CTransaction& tx, vResurrect) {
// ignore validation errors in resurrected transactions // ignore validation errors in resurrected transactions
CValidationState stateDummy; 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 // Delete redundant memory transactions that are in the connected branch

Loading…
Cancel
Save