@@ -255,22 +255,23 @@ bool TestLockPointValidity(const LockPoints* lp)
255
255
return true ;
256
256
}
257
257
258
- bool CheckSequenceLocks (const CTxMemPool& pool, const CTransaction& tx, int flags, LockPoints* lp, bool useExistingLockPoints)
258
+ bool CheckSequenceLocks (CChainState& active_chainstate, const CTxMemPool& pool, const CTransaction& tx, int flags, LockPoints* lp, bool useExistingLockPoints)
259
259
{
260
260
AssertLockHeld (cs_main);
261
261
AssertLockHeld (pool.cs );
262
+ assert (std::addressof (::ChainstateActive ()) == std::addressof (active_chainstate));
262
263
263
- CBlockIndex* tip = :: ChainActive () .Tip ();
264
+ CBlockIndex* tip = active_chainstate. m_chain .Tip ();
264
265
assert (tip != nullptr );
265
266
266
267
CBlockIndex index;
267
268
index.pprev = tip;
268
- // CheckSequenceLocks() uses ::ChainActive() .Height()+1 to evaluate
269
+ // CheckSequenceLocks() uses active_chainstate.m_chain .Height()+1 to evaluate
269
270
// height based locks because when SequenceLocks() is called within
270
271
// ConnectBlock(), the height of the block *being*
271
272
// evaluated is what is used.
272
273
// Thus if we want to know if a transaction can be part of the
273
- // *next* block, we need to use one more than ::ChainActive() .Height()
274
+ // *next* block, we need to use one more than active_chainstate.m_chain .Height()
274
275
index.nHeight = tip->nHeight + 1 ;
275
276
276
277
std::pair<int , int64_t > lockPair;
@@ -280,8 +281,8 @@ bool CheckSequenceLocks(const CTxMemPool& pool, const CTransaction& tx, int flag
280
281
lockPair.second = lp->time ;
281
282
}
282
283
else {
283
- // CoinsTip() contains the UTXO set for ::ChainActive() .Tip()
284
- CCoinsViewMemPool viewMemPool (&:: ChainstateActive () .CoinsTip (), pool);
284
+ // CoinsTip() contains the UTXO set for active_chainstate.m_chain .Tip()
285
+ CCoinsViewMemPool viewMemPool (&active_chainstate .CoinsTip (), pool);
285
286
std::vector<int > prevheights;
286
287
prevheights.resize (tx.vin .size ());
287
288
for (size_t txinIndex = 0 ; txinIndex < tx.vin .size (); txinIndex++) {
@@ -684,7 +685,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
684
685
// be mined yet.
685
686
// Must keep pool.cs for this unless we change CheckSequenceLocks to take a
686
687
// CoinsViewCache instead of create its own
687
- if (!CheckSequenceLocks (m_pool, tx, STANDARD_LOCKTIME_VERIFY_FLAGS, &lp))
688
+ if (!CheckSequenceLocks (:: ChainstateActive (), m_pool, tx, STANDARD_LOCKTIME_VERIFY_FLAGS, &lp))
688
689
return state.Invalid (TxValidationResult::TX_PREMATURE_SPEND, " non-BIP68-final" );
689
690
690
691
if (!Consensus::CheckTxInputs (tx, state, m_view, g_chainman.m_blockman .GetSpendHeight (m_view), ws.m_base_fees )) {
0 commit comments