Skip to content

Commit 71734c6

Browse files
committed
validation: Pass in chain to ::TestLockPointValidity
1 parent 120aaba commit 71734c6

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/txmempool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
511511
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
512512
const CTransaction& tx = it->GetTx();
513513
LockPoints lp = it->GetLockPoints();
514-
bool validLP = TestLockPointValidity(&lp);
514+
bool validLP = TestLockPointValidity(::ChainActive(), &lp);
515515
if (!CheckFinalTx(::ChainActive().Tip(), tx, flags) || !CheckSequenceLocks(::ChainstateActive(), *this, tx, flags, &lp, validLP)) {
516516
// Note if CheckSequenceLocks fails the LockPoints may still be invalid
517517
// So it's critical that we remove the tx and not depend on the LockPoints.

src/validation.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ bool CheckFinalTx(const CBlockIndex* active_chain_tip, const CTransaction &tx, i
237237
return IsFinalTx(tx, nBlockHeight, nBlockTime);
238238
}
239239

240-
bool TestLockPointValidity(const LockPoints* lp)
240+
bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp)
241241
{
242242
AssertLockHeld(cs_main);
243243
assert(lp);
@@ -246,7 +246,8 @@ bool TestLockPointValidity(const LockPoints* lp)
246246
if (lp->maxInputBlock) {
247247
// Check whether ::ChainActive() is an extension of the block at which the LockPoints
248248
// calculation was valid. If not LockPoints are no longer valid
249-
if (!::ChainActive().Contains(lp->maxInputBlock)) {
249+
assert(std::addressof(::ChainActive()) == std::addressof(active_chain));
250+
if (!active_chain.Contains(lp->maxInputBlock)) {
250251
return false;
251252
}
252253
}

src/validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ bool CheckFinalTx(const CBlockIndex* active_chain_tip, const CTransaction &tx, i
253253
/**
254254
* Test whether the LockPoints height and time are still valid on the current chain
255255
*/
256-
bool TestLockPointValidity(const LockPoints* lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
256+
bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
257257

258258
/**
259259
* Check if transaction will be BIP 68 final in the next block to be created.

0 commit comments

Comments
 (0)