Skip to content

Commit e85862b

Browse files
committed
merge bitcoin#23649: circular dependency followups
1 parent 8ab9929 commit e85862b

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/txmempool.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <txmempool.h>
77

8+
#include <chain.h>
89
#include <coins.h>
910
#include <consensus/consensus.h>
1011
#include <consensus/tx_verify.h>
@@ -81,16 +82,15 @@ struct update_lock_points
8182
const LockPoints& lp;
8283
};
8384

84-
bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp)
85+
bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp)
8586
{
8687
AssertLockHeld(cs_main);
87-
assert(lp);
8888
// If there are relative lock times then the maxInputBlock will be set
8989
// If there are no relative lock times, the LockPoints don't depend on the chain
90-
if (lp->maxInputBlock) {
90+
if (lp.maxInputBlock) {
9191
// Check whether active_chain is an extension of the block at which the LockPoints
9292
// calculation was valid. If not LockPoints are no longer valid
93-
if (!active_chain.Contains(lp->maxInputBlock)) {
93+
if (!active_chain.Contains(lp.maxInputBlock)) {
9494
return false;
9595
}
9696
}
@@ -892,8 +892,8 @@ void CTxMemPool::removeForReorg(CChain& chain, std::function<bool(txiter)> check
892892
}
893893
RemoveStaged(setAllRemoves, false, MemPoolRemovalReason::REORG);
894894
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
895-
LockPoints lp = it->GetLockPoints();
896-
if (!TestLockPointValidity(chain, &lp)) {
895+
const LockPoints lp{it->GetLockPoints()};
896+
if (!TestLockPointValidity(chain, lp)) {
897897
mapTx.modify(it, update_lock_points(lp));
898898
}
899899
}

src/txmempool.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <addressindex.h>
1818
#include <spentindex.h>
1919
#include <amount.h>
20-
#include <chain.h>
2120
#include <coins.h>
2221
#include <gsl/pointers.h>
2322
#include <indirectmap.h>
@@ -31,12 +30,13 @@
3130
#include <util/epochguard.h>
3231
#include <util/hasher.h>
3332

34-
#include <boost/multi_index_container.hpp>
3533
#include <boost/multi_index/hashed_index.hpp>
3634
#include <boost/multi_index/ordered_index.hpp>
3735
#include <boost/multi_index/sequenced_index.hpp>
36+
#include <boost/multi_index_container.hpp>
3837

3938
class CBlockIndex;
39+
class CChain;
4040
class CChainState;
4141
extern RecursiveMutex cs_main;
4242

@@ -63,7 +63,7 @@ struct LockPoints {
6363
/**
6464
* Test whether the LockPoints height and time are still valid on the current chain
6565
*/
66-
bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
66+
bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
6767

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

src/validation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ void CChainState::MaybeUpdateMempoolForReorg(
378378
AssertLockHeld(::cs_main);
379379
const CTransaction& tx = it->GetTx();
380380
LockPoints lp = it->GetLockPoints();
381-
bool validLP = TestLockPointValidity(m_chain, &lp);
381+
const bool validLP{TestLockPointValidity(m_chain, lp)};
382382
CCoinsViewMemPool view_mempool(&CoinsTip(), *m_mempool);
383383
if (!CheckFinalTx(m_chain.Tip(), tx, flags)
384384
|| !CheckSequenceLocks(m_chain.Tip(), view_mempool, tx, flags, &lp, validLP)) {
@@ -392,8 +392,8 @@ void CChainState::MaybeUpdateMempoolForReorg(
392392
continue;
393393
const Coin &coin = CoinsTip().AccessCoin(txin.prevout);
394394
assert(!coin.IsSpent());
395-
unsigned int nMemPoolHeight = m_chain.Tip()->nHeight + 1;
396-
if (coin.IsSpent() || (coin.IsCoinBase() && ((signed long)nMemPoolHeight) - coin.nHeight < COINBASE_MATURITY)) {
395+
const auto mempool_spend_height{m_chain.Tip()->nHeight + 1};
396+
if (coin.IsSpent() || (coin.IsCoinBase() && mempool_spend_height - coin.nHeight < COINBASE_MATURITY)) {
397397
should_remove = true;
398398
break;
399399
}

0 commit comments

Comments
 (0)