merge bitcoin#23683: valid but different LockPoints after a reorg

This commit is contained in:
Kittywhiskers Van Gogh 2021-12-03 18:00:00 +00:00
parent e85862ba11
commit 150ca008fe
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
3 changed files with 13 additions and 14 deletions

View File

@ -72,16 +72,6 @@ private:
int64_t feeDelta; int64_t feeDelta;
}; };
struct update_lock_points
{
explicit update_lock_points(const LockPoints& _lp) : lp(_lp) { }
void operator() (CTxMemPoolEntry &e) { e.UpdateLockPoints(lp); }
private:
const LockPoints& lp;
};
bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp) bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp)
{ {
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
@ -892,10 +882,7 @@ void CTxMemPool::removeForReorg(CChain& chain, std::function<bool(txiter)> check
} }
RemoveStaged(setAllRemoves, false, MemPoolRemovalReason::REORG); RemoveStaged(setAllRemoves, false, MemPoolRemovalReason::REORG);
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) { for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
const LockPoints lp{it->GetLockPoints()}; assert(TestLockPointValidity(chain, it->GetLockPoints()));
if (!TestLockPointValidity(chain, lp)) {
mapTx.modify(it, update_lock_points(lp));
}
} }
} }

View File

@ -308,6 +308,16 @@ public:
} }
}; };
struct update_lock_points
{
explicit update_lock_points(const LockPoints& _lp) : lp(_lp) { }
void operator() (CTxMemPoolEntry &e) { e.UpdateLockPoints(lp); }
private:
const LockPoints& lp;
};
// Multi_index tag names // Multi_index tag names
struct descendant_score {}; struct descendant_score {};
struct entry_time {}; struct entry_time {};

View File

@ -399,6 +399,8 @@ void CChainState::MaybeUpdateMempoolForReorg(
} }
} }
} }
// CheckSequenceLocks updates lp. Update the mempool entry LockPoints.
if (!validLP) m_mempool->mapTx.modify(it, update_lock_points(lp));
return should_remove; return should_remove;
}; };