Fix non-standard disconnected transactions causing mempool orphans
This commit is contained in:
parent
4323bfeafd
commit
f0784ac470
1 changed files with 9 additions and 8 deletions
17
src/main.cpp
17
src/main.cpp
|
@ -973,15 +973,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<COutPoint, CInPoint>::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<COutPoint, CInPoint>::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);
|
||||
|
@ -2083,7 +2083,8 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
|
|||
BOOST_FOREACH(CTransaction& tx, vResurrect) {
|
||||
// ignore validation errors in resurrected transactions
|
||||
CValidationState stateDummy;
|
||||
mempool.accept(stateDummy, tx, false, NULL);
|
||||
if (!mempool.accept(stateDummy, tx, false, NULL))
|
||||
mempool.remove(tx, true);
|
||||
}
|
||||
|
||||
// Delete redundant memory transactions that are in the connected branch
|
||||
|
|
Loading…
Reference in a new issue