Keep mempool consistent after conflicting withdraw-spent

This commit is contained in:
Matt Corallo 2016-03-18 21:24:04 -07:00 committed by Gregory Sanders
parent 79d422acfa
commit 54f981de1f
5 changed files with 21 additions and 7 deletions

View file

@ -603,6 +603,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::list<CTransaction>
* Called when a block is connected. Removes from mempool and updates the miner fee estimator.
*/
void CTxMemPool::removeForBlock(const std::vector<CTransaction>& vtx, unsigned int nBlockHeight,
const std::set<std::pair<uint256, COutPoint> >& setWithdrawsSpent,
std::list<CTransaction>& conflicts, bool fCurrentEstimate)
{
LOCK(cs);
@ -626,6 +627,16 @@ void CTxMemPool::removeForBlock(const std::vector<CTransaction>& vtx, unsigned i
removeConflicts(tx, conflicts);
ClearPrioritisation(tx.GetHash());
}
for (std::set<std::pair<uint256, COutPoint> >::const_iterator it = setWithdrawsSpent.begin(); it != setWithdrawsSpent.end(); it++) {
std::map<std::pair<uint256, COutPoint>, uint256>::const_iterator it2 = mapWithdrawsSpentToTxid.find(*it);
if (it2 != mapWithdrawsSpentToTxid.end()) {
txiter txit = mapTx.find(it2->second);
assert(txit != mapTx.end());
setEntries stage;
stage.insert(txit);
RemoveStaged(stage, true);
}
}
// After the txs in the new block have been removed from the mempool, update policy estimates
minerPolicyEstimator->processBlock(nBlockHeight, entries, fCurrentEstimate);
lastRollingFeeUpdate = GetTime();