diff --git a/src/txmempool.h b/src/txmempool.h --- a/src/txmempool.h +++ b/src/txmempool.h @@ -30,6 +30,7 @@ #include class CBlockIndex; +class CChain; class CChainState; class Config; @@ -53,6 +54,13 @@ CBlockIndex *maxInputBlock{nullptr}; }; +/** + * Test whether the LockPoints height and time are still valid on the current + * chain. + */ +bool TestLockPointValidity(const CChain &active_chain, const LockPoints *lp) + EXCLUSIVE_LOCKS_REQUIRED(cs_main); + struct CompareIteratorById { // SFINAE for T where T is either a pointer type (e.g., a txiter) or a // reference_wrapper (e.g. a wrapped CTxMemPoolEntry&) diff --git a/src/txmempool.cpp b/src/txmempool.cpp --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -82,6 +82,25 @@ const LockPoints &lp; }; +bool TestLockPointValidity(const CChain &active_chain, const LockPoints *lp) { + AssertLockHeld(cs_main); + assert(lp); + // If there are relative lock times then the maxInputBlock will be set + // If there are no relative lock times, the LockPoints don't depend on the + // chain + if (lp->maxInputBlock) { + // Check whether active_chain is an extension of the block at which the + // LockPoints calculation was valid. If not LockPoints are no longer + // valid + if (!active_chain.Contains(lp->maxInputBlock)) { + return false; + } + } + + // LockPoints still valid + return true; +} + CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef &_tx, const Amount fee, int64_t time, unsigned int entry_height, bool spends_coinbase, int64_t sigops_count, diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -470,13 +470,6 @@ void UpdateCoins(CCoinsViewCache &view, const CTransaction &tx, CTxUndo &txundo, int nHeight); -/** - * Test whether the LockPoints height and time are still valid on the current - * chain. - */ -bool TestLockPointValidity(const CChain &active_chain, const LockPoints *lp) - EXCLUSIVE_LOCKS_REQUIRED(cs_main); - /** * Check if transaction will be BIP68 final in the next block to be created on * top of tip. diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -156,25 +156,6 @@ static uint32_t GetNextBlockScriptFlags(const Consensus::Params ¶ms, const CBlockIndex *pindex); -bool TestLockPointValidity(const CChain &active_chain, const LockPoints *lp) { - AssertLockHeld(cs_main); - assert(lp); - // If there are relative lock times then the maxInputBlock will be set - // If there are no relative lock times, the LockPoints don't depend on the - // chain - if (lp->maxInputBlock) { - // Check whether active_chain is an extension of the block at which - // the LockPoints calculation was valid. If not LockPoints are no longer - // valid. - if (!active_chain.Contains(lp->maxInputBlock)) { - return false; - } - } - - // LockPoints still valid - return true; -} - bool CheckSequenceLocks(CBlockIndex *tip, const CCoinsView &coins_view, const CTransaction &tx, int flags, LockPoints *lp, bool useExistingLockPoints) {