mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 07:39:08 +01:00
Fix non-standard disconnected transactions causing mempool orphans
Conflicts: src/main.cpp
This commit is contained in:
committed by
Gavin Andresen
parent
5e18c6ccbc
commit
d7fdc5fac3
17
src/main.cpp
17
src/main.cpp
@@ -837,15 +837,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);
|
||||
@@ -1853,7 +1853,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
|
||||
|
||||
Reference in New Issue
Block a user