@ -245,18 +245,13 @@ bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp)
return true ;
return true ;
}
}
bool CheckSequenceLocks ( C ChainState& active_chainstate ,
bool CheckSequenceLocks ( C BlockIndex* tip ,
const C TxMemPool& pool ,
const C CoinsView& coins_view ,
const CTransaction & tx ,
const CTransaction & tx ,
int flags ,
int flags ,
LockPoints * lp ,
LockPoints * lp ,
bool useExistingLockPoints )
bool useExistingLockPoints )
{
{
AssertLockHeld ( cs_main ) ;
AssertLockHeld ( pool . cs ) ;
assert ( std : : addressof ( : : ChainstateActive ( ) ) = = std : : addressof ( active_chainstate ) ) ;
CBlockIndex * tip = active_chainstate . m_chain . Tip ( ) ;
assert ( tip ! = nullptr ) ;
assert ( tip ! = nullptr ) ;
CBlockIndex index ;
CBlockIndex index ;
@ -276,14 +271,12 @@ bool CheckSequenceLocks(CChainState& active_chainstate,
lockPair . second = lp - > time ;
lockPair . second = lp - > time ;
}
}
else {
else {
// CoinsTip() contains the UTXO set for active_chainstate.m_chain.Tip()
CCoinsViewMemPool viewMemPool ( & active_chainstate . CoinsTip ( ) , pool ) ;
std : : vector < int > prevheights ;
std : : vector < int > prevheights ;
prevheights . resize ( tx . vin . size ( ) ) ;
prevheights . resize ( tx . vin . size ( ) ) ;
for ( size_t txinIndex = 0 ; txinIndex < tx . vin . size ( ) ; txinIndex + + ) {
for ( size_t txinIndex = 0 ; txinIndex < tx . vin . size ( ) ; txinIndex + + ) {
const CTxIn & txin = tx . vin [ txinIndex ] ;
const CTxIn & txin = tx . vin [ txinIndex ] ;
Coin coin ;
Coin coin ;
if ( ! viewMemPool . GetCoin ( txin . prevout , coin ) ) {
if ( ! coins_ view. GetCoin ( txin . prevout , coin ) ) {
return error ( " %s: Missing input " , __func__ ) ;
return error ( " %s: Missing input " , __func__ ) ;
}
}
if ( coin . nHeight = = MEMPOOL_HEIGHT ) {
if ( coin . nHeight = = MEMPOOL_HEIGHT ) {
@ -686,10 +679,10 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
// Only accept BIP68 sequence locked transactions that can be mined in the next
// Only accept BIP68 sequence locked transactions that can be mined in the next
// block; we don't want our mempool filled up with transactions that can't
// block; we don't want our mempool filled up with transactions that can't
// be mined yet.
// be mined yet.
// Must keep pool.cs for this unless we change CheckSequenceLocks to take a
// Pass in m_view which has all of the relevant inputs cached. Note that, since m_view's
// CoinsViewCache instead of create its own
// backend was removed, it no longer pulls coins from the mempool.
assert ( std : : addressof ( : : ChainstateActive ( ) ) = = std : : addressof ( m_active_chainstate ) ) ;
assert ( std : : addressof ( : : ChainstateActive ( ) ) = = std : : addressof ( m_active_chainstate ) ) ;
if ( ! CheckSequenceLocks ( m_active_chainstate , m_pool , tx , STANDARD_LOCKTIME_VERIFY_FLAGS , & lp ) )
if ( ! CheckSequenceLocks ( m_active_chainstate .m_chain . Tip ( ) , m_view , tx , STANDARD_LOCKTIME_VERIFY_FLAGS , & lp ) )
return state . Invalid ( TxValidationResult : : TX_PREMATURE_SPEND , " non-BIP68-final " ) ;
return state . Invalid ( TxValidationResult : : TX_PREMATURE_SPEND , " non-BIP68-final " ) ;
assert ( std : : addressof ( g_chainman . m_blockman ) = = std : : addressof ( m_active_chainstate . m_blockman ) ) ;
assert ( std : : addressof ( g_chainman . m_blockman ) = = std : : addressof ( m_active_chainstate . m_blockman ) ) ;