diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 4708facc75..cb16e2ddfc 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -72,16 +72,6 @@ private: 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); @@ -892,10 +882,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 d2d7d792de..6067ec8ed3 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -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 struct descendant_score {}; struct entry_time {}; diff --git a/src/validation.cpp b/src/validation.cpp index a95697e723..08109aafd9 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -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; };