Erase orphans per-transaction instead of per-block

This commit is contained in:
Matt Corallo 2016-11-03 14:53:12 -04:00
parent ec4525ccc1
commit 97e28029c9

View file

@ -3088,8 +3088,8 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
// Remove orphan transactions with cs_main // Remove orphan transactions with cs_main
{ {
LOCK(cs_main); LOCK(cs_main);
std::vector<uint256> vOrphanErase;
for(unsigned int i = 0; i < txChanged.size(); i++) { for(unsigned int i = 0; i < txChanged.size(); i++) {
std::vector<uint256> vOrphanErase;
const CTransaction& tx = std::get<0>(txChanged[i]); const CTransaction& tx = std::get<0>(txChanged[i]);
// Which orphan pool entries must we evict? // Which orphan pool entries must we evict?
for (size_t j = 0; j < tx.vin.size(); j++) { for (size_t j = 0; j < tx.vin.size(); j++) {
@ -3101,14 +3101,15 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
vOrphanErase.push_back(orphanHash); vOrphanErase.push_back(orphanHash);
} }
} }
}
// Erase orphan transactions include or precluded by this block // Erase orphan transactions include or precluded by this block
if (vOrphanErase.size()) { if (vOrphanErase.size()) {
int nErased = 0; int nErased = 0;
BOOST_FOREACH(uint256 &orphanHash, vOrphanErase) { BOOST_FOREACH(uint256 &orphanHash, vOrphanErase) {
nErased += EraseOrphanTx(orphanHash); nErased += EraseOrphanTx(orphanHash);
}
LogPrint("mempool", "Erased %d orphan tx included or conflicted by block\n", nErased);
} }
LogPrint("mempool", "Erased %d orphan tx included or conflicted by block\n", nErased);
} }
} }