aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Dong <contact@carldong.me>2020-09-16 17:40:00 -0400
committerCarl Dong <contact@carldong.me>2021-02-18 14:49:10 -0500
commit71734c65dc491a4bb654ccbb7a1dd0e12131cee4 (patch)
tree96da01e7a131140c02a2085711ec8b17ec927493
parent120aaba9ac41af71a760aa0969dd090e96786fb3 (diff)
downloadbitcoin-71734c65dc491a4bb654ccbb7a1dd0e12131cee4.tar.xz
validation: Pass in chain to ::TestLockPointValidity
-rw-r--r--src/txmempool.cpp2
-rw-r--r--src/validation.cpp5
-rw-r--r--src/validation.h2
3 files changed, 5 insertions, 4 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 197cd6cd4b..031077fa75 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -511,7 +511,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
const CTransaction& tx = it->GetTx();
LockPoints lp = it->GetLockPoints();
- bool validLP = TestLockPointValidity(&lp);
+ bool validLP = TestLockPointValidity(::ChainActive(), &lp);
if (!CheckFinalTx(::ChainActive().Tip(), tx, flags) || !CheckSequenceLocks(::ChainstateActive(), *this, tx, flags, &lp, validLP)) {
// Note if CheckSequenceLocks fails the LockPoints may still be invalid
// So it's critical that we remove the tx and not depend on the LockPoints.
diff --git a/src/validation.cpp b/src/validation.cpp
index 0b4f0dbb4c..870f41a16f 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -237,7 +237,7 @@ bool CheckFinalTx(const CBlockIndex* active_chain_tip, const CTransaction &tx, i
return IsFinalTx(tx, nBlockHeight, nBlockTime);
}
-bool TestLockPointValidity(const LockPoints* lp)
+bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp)
{
AssertLockHeld(cs_main);
assert(lp);
@@ -246,7 +246,8 @@ bool TestLockPointValidity(const LockPoints* lp)
if (lp->maxInputBlock) {
// Check whether ::ChainActive() is an extension of the block at which the LockPoints
// calculation was valid. If not LockPoints are no longer valid
- if (!::ChainActive().Contains(lp->maxInputBlock)) {
+ assert(std::addressof(::ChainActive()) == std::addressof(active_chain));
+ if (!active_chain.Contains(lp->maxInputBlock)) {
return false;
}
}
diff --git a/src/validation.h b/src/validation.h
index 739f4f1d99..7fc0d31c70 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -253,7 +253,7 @@ bool CheckFinalTx(const CBlockIndex* active_chain_tip, const CTransaction &tx, i
/**
* Test whether the LockPoints height and time are still valid on the current chain
*/
-bool TestLockPointValidity(const LockPoints* lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
+bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
/**
* Check if transaction will be BIP 68 final in the next block to be created.