diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 66beb0a9b3a5c..dc2769b81ed5e 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -64,16 +64,6 @@ struct update_fee_delta 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) { AssertLockHeld(cs_main); @@ -649,10 +639,7 @@ void CTxMemPool::removeForReorg(CChain& chain, std::function check } RemoveStaged(setAllRemoves, false, MemPoolRemovalReason::REORG); for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) { - const LockPoints lp{it->GetLockPoints()}; - if (!TestLockPointValidity(chain, lp)) { - mapTx.modify(it, update_lock_points(lp)); - } + assert(TestLockPointValidity(chain, it->GetLockPoints())); } } diff --git a/src/txmempool.h b/src/txmempool.h index df578d51112a8..b8c508fd9065b 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -312,6 +312,16 @@ class CompareTxMemPoolEntryByAncestorFee } }; +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 struct descendant_score {}; struct entry_time {}; diff --git a/src/validation.cpp b/src/validation.cpp index cb2b60b481e59..fba3ef26c7edc 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -375,6 +375,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; };