diff options
author | glozow <gloriajzhao@gmail.com> | 2021-11-30 11:21:02 +0000 |
---|---|---|
committer | glozow <gloriajzhao@gmail.com> | 2021-11-30 11:56:46 +0000 |
commit | 1b3a11e126b258fba975ed7c452221608f2c5472 (patch) | |
tree | cb15b7aebd9f281a7fc41d57c8c6521f40c03762 /src | |
parent | e521c5589e253b1a6631d085b3ac578751883082 (diff) | |
download | bitcoin-1b3a11e126b258fba975ed7c452221608f2c5472.tar.xz |
MOVEONLY: TestLockPointValidity to txmempool
Diffstat (limited to 'src')
-rw-r--r-- | src/txmempool.cpp | 18 | ||||
-rw-r--r-- | src/txmempool.h | 6 | ||||
-rw-r--r-- | src/validation.cpp | 18 | ||||
-rw-r--r-- | src/validation.h | 5 |
4 files changed, 24 insertions, 23 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 502a27dc6b..05b22bb39b 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -74,6 +74,24 @@ private: const LockPoints& lp; }; +bool TestLockPointValidity(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, CAmount fee, int64_t time, unsigned int entry_height, bool spends_coinbase, int64_t sigops_cost, LockPoints lp) diff --git a/src/txmempool.h b/src/txmempool.h index 85417ac3fc..412c2fbb74 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -14,6 +14,7 @@ #include <utility> #include <vector> +#include <chain.h> #include <coins.h> #include <consensus/amount.h> #include <indirectmap.h> @@ -49,6 +50,11 @@ struct LockPoints { CBlockIndex* maxInputBlock{nullptr}; }; +/** + * Test whether the LockPoints height and time are still valid on the current chain + */ +bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main); + struct CompareIteratorByHash { // SFINAE for T where T is either a pointer type (e.g., a txiter) or a reference_wrapper<T> // (e.g. a wrapped CTxMemPoolEntry&) diff --git a/src/validation.cpp b/src/validation.cpp index c96adb77ff..322e77afe6 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -212,24 +212,6 @@ bool CheckFinalTx(const CBlockIndex* active_chain_tip, const CTransaction &tx, i return IsFinalTx(tx, nBlockHeight, nBlockTime); } -bool TestLockPointValidity(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, diff --git a/src/validation.h b/src/validation.h index 21cd389757..a81188b5f2 100644 --- a/src/validation.h +++ b/src/validation.h @@ -250,11 +250,6 @@ PackageMempoolAcceptResult ProcessNewPackage(CChainState& active_chainstate, CTx bool CheckFinalTx(const CBlockIndex* active_chain_tip, const CTransaction &tx, int flags = -1) EXCLUSIVE_LOCKS_REQUIRED(cs_main); /** - * Test whether the LockPoints height and time are still valid on the current chain - */ -bool TestLockPointValidity(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. * @param[in] tip Chain tip to check tx sequence locks against. For example, * the tip of the current active chain. |