mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
[validation] make CheckSequenceLocks context-free
Allow CheckSequenceLocks to use heights and coins from any CoinsView and CBlockIndex provided. This means that CheckSequenceLocks() doesn't need to hold the mempool lock or cs_main. The caller is responsible for ensuring the CoinsView and CBlockIndex are consistent before passing them in. The typical usage is still to create a CCoinsViewMemPool from the mempool and grab the CBlockIndex from the chainstate tip.
This commit is contained in:
@@ -226,9 +226,13 @@ bool CheckFinalTx(const CBlockIndex* active_chain_tip, const CTransaction &tx, i
|
||||
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.
|
||||
*
|
||||
* Simulates calling SequenceLocks() with data from the tip of the current active chain.
|
||||
* Check if transaction will be BIP68 final in the next block to be created on top of tip.
|
||||
* @param[in] tip Chain tip to check tx sequence locks against. For example,
|
||||
* the tip of the current active chain.
|
||||
* @param[in] coins_view Any CCoinsView that provides access to the relevant coins
|
||||
* for checking sequence locks. Any CCoinsView can be passed in;
|
||||
* it is assumed to be consistent with the tip.
|
||||
* Simulates calling SequenceLocks() with data from the tip passed in.
|
||||
* Optionally stores in LockPoints the resulting height and time calculated and the hash
|
||||
* of the block needed for calculation or skips the calculation and uses the LockPoints
|
||||
* passed in for evaluation.
|
||||
@@ -236,12 +240,12 @@ bool TestLockPointValidity(CChain& active_chain, const LockPoints* lp) EXCLUSIVE
|
||||
*
|
||||
* See consensus/consensus.h for flag definitions.
|
||||
*/
|
||||
bool CheckSequenceLocks(CChainState& active_chainstate,
|
||||
const CTxMemPool& pool,
|
||||
bool CheckSequenceLocks(CBlockIndex* tip,
|
||||
const CCoinsView& coins_view,
|
||||
const CTransaction& tx,
|
||||
int flags,
|
||||
LockPoints* lp = nullptr,
|
||||
bool useExistingLockPoints = false) EXCLUSIVE_LOCKS_REQUIRED(::cs_main, pool.cs);
|
||||
bool useExistingLockPoints = false);
|
||||
|
||||
/**
|
||||
* Closure representing one script verification
|
||||
|
||||
Reference in New Issue
Block a user