Skip to content

Commit 1b3a11e

Browse files
committed
MOVEONLY: TestLockPointValidity to txmempool
1 parent e521c55 commit 1b3a11e

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

src/txmempool.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,24 @@ struct update_lock_points
7474
const LockPoints& lp;
7575
};
7676

77+
bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp)
78+
{
79+
AssertLockHeld(cs_main);
80+
assert(lp);
81+
// If there are relative lock times then the maxInputBlock will be set
82+
// If there are no relative lock times, the LockPoints don't depend on the chain
83+
if (lp->maxInputBlock) {
84+
// Check whether active_chain is an extension of the block at which the LockPoints
85+
// calculation was valid. If not LockPoints are no longer valid
86+
if (!active_chain.Contains(lp->maxInputBlock)) {
87+
return false;
88+
}
89+
}
90+
91+
// LockPoints still valid
92+
return true;
93+
}
94+
7795
CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
7896
int64_t time, unsigned int entry_height,
7997
bool spends_coinbase, int64_t sigops_cost, LockPoints lp)

src/txmempool.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <utility>
1515
#include <vector>
1616

17+
#include <chain.h>
1718
#include <coins.h>
1819
#include <consensus/amount.h>
1920
#include <indirectmap.h>
@@ -49,6 +50,11 @@ struct LockPoints {
4950
CBlockIndex* maxInputBlock{nullptr};
5051
};
5152

53+
/**
54+
* Test whether the LockPoints height and time are still valid on the current chain
55+
*/
56+
bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
57+
5258
struct CompareIteratorByHash {
5359
// SFINAE for T where T is either a pointer type (e.g., a txiter) or a reference_wrapper<T>
5460
// (e.g. a wrapped CTxMemPoolEntry&)

src/validation.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -212,24 +212,6 @@ bool CheckFinalTx(const CBlockIndex* active_chain_tip, const CTransaction &tx, i
212212
return IsFinalTx(tx, nBlockHeight, nBlockTime);
213213
}
214214

215-
bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp)
216-
{
217-
AssertLockHeld(cs_main);
218-
assert(lp);
219-
// If there are relative lock times then the maxInputBlock will be set
220-
// If there are no relative lock times, the LockPoints don't depend on the chain
221-
if (lp->maxInputBlock) {
222-
// Check whether active_chain is an extension of the block at which the LockPoints
223-
// calculation was valid. If not LockPoints are no longer valid
224-
if (!active_chain.Contains(lp->maxInputBlock)) {
225-
return false;
226-
}
227-
}
228-
229-
// LockPoints still valid
230-
return true;
231-
}
232-
233215
bool CheckSequenceLocks(CBlockIndex* tip,
234216
const CCoinsView& coins_view,
235217
const CTransaction& tx,

src/validation.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,6 @@ PackageMempoolAcceptResult ProcessNewPackage(CChainState& active_chainstate, CTx
249249
*/
250250
bool CheckFinalTx(const CBlockIndex* active_chain_tip, const CTransaction &tx, int flags = -1) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
251251

252-
/**
253-
* Test whether the LockPoints height and time are still valid on the current chain
254-
*/
255-
bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
256-
257252
/**
258253
* Check if transaction will be BIP68 final in the next block to be created on top of tip.
259254
* @param[in] tip Chain tip to check tx sequence locks against. For example,

0 commit comments

Comments
 (0)