Skip to content

Commit c4efc4d

Browse files
committed
change TestLockPointValidity to take a const reference
The lockpoints are not changed in this function. There is no reason to pass a pointer.
1 parent b01784f commit c4efc4d

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

src/txmempool.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,15 @@ struct update_lock_points
7373
const LockPoints& lp;
7474
};
7575

76-
bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp)
76+
bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp)
7777
{
7878
AssertLockHeld(cs_main);
79-
assert(lp);
8079
// If there are relative lock times then the maxInputBlock will be set
8180
// If there are no relative lock times, the LockPoints don't depend on the chain
82-
if (lp->maxInputBlock) {
81+
if (lp.maxInputBlock) {
8382
// Check whether active_chain is an extension of the block at which the LockPoints
8483
// calculation was valid. If not LockPoints are no longer valid
85-
if (!active_chain.Contains(lp->maxInputBlock)) {
84+
if (!active_chain.Contains(lp.maxInputBlock)) {
8685
return false;
8786
}
8887
}
@@ -649,8 +648,8 @@ void CTxMemPool::removeForReorg(CChain& chain, std::function<bool(txiter)> check
649648
}
650649
RemoveStaged(setAllRemoves, false, MemPoolRemovalReason::REORG);
651650
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
652-
LockPoints lp = it->GetLockPoints();
653-
if (!TestLockPointValidity(chain, &lp)) {
651+
const LockPoints lp{it->GetLockPoints()};
652+
if (!TestLockPointValidity(chain, lp)) {
654653
mapTx.modify(it, update_lock_points(lp));
655654
}
656655
}

src/txmempool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct LockPoints {
5353
/**
5454
* Test whether the LockPoints height and time are still valid on the current chain
5555
*/
56-
bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
56+
bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
5757

5858
struct CompareIteratorByHash {
5959
// SFINAE for T where T is either a pointer type (e.g., a txiter) or a reference_wrapper<T>

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ void CChainState::MaybeUpdateMempoolForReorg(
357357
AssertLockHeld(::cs_main);
358358
const CTransaction& tx = it->GetTx();
359359
LockPoints lp = it->GetLockPoints();
360-
const bool validLP{TestLockPointValidity(m_chain, &lp)};
360+
const bool validLP{TestLockPointValidity(m_chain, lp)};
361361
CCoinsViewMemPool view_mempool(&CoinsTip(), *m_mempool);
362362
if (!CheckFinalTx(m_chain.Tip(), tx, flags)
363363
|| !CheckSequenceLocks(m_chain.Tip(), view_mempool, tx, flags, &lp, validLP)) {

0 commit comments

Comments
 (0)