Skip to content

Commit 85f4a75

Browse files
committed
pak mempool removal: don't modify the vector you are taking range over
1 parent 5f93331 commit 85f4a75

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/txmempool.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -615,21 +615,24 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne
615615
// Eject any newly-invalid peg-outs based on changing block commitment
616616
const CChainParams& chainparams = Params();
617617
if (pak_transition && chainparams.GetEnforcePak()) {
618+
std::vector<CTransactionRef> tx_to_remove;
618619
for (const auto& entry : mapTx) {
619620
for (const auto& out : entry.GetTx().vout) {
620621
if (out.scriptPubKey.IsPegoutScript(Params().ParentGenesisBlockHash()) &&
621622
!ScriptHasValidPAKProof(out.scriptPubKey, Params().ParentGenesisBlockHash())) {
622623
const uint256 tx_id = entry.GetTx().GetHash();
623624
txiter it = mapTx.find(tx_id);
624625
const CTransaction& tx = it->GetTx();
625-
setEntries stage;
626-
stage.insert(it);
627-
removeRecursive(tx, MemPoolRemovalReason::BLOCK);
628-
ClearPrioritisation(tx_id);
626+
tx_to_remove.push_back(MakeTransactionRef(tx));
629627
break;
630628
}
631629
}
632630
}
631+
for (auto& tx : tx_to_remove) {
632+
const uint256 tx_id = tx->GetHash();
633+
removeRecursive(*tx, MemPoolRemovalReason::BLOCK);
634+
ClearPrioritisation(tx_id);
635+
}
633636
}
634637
lastRollingFeeUpdate = GetTime();
635638
blockSinceLastRollingFeeBump = true;

0 commit comments

Comments
 (0)