aboutsummaryrefslogtreecommitdiff
path: root/src/validation.h
diff options
context:
space:
mode:
authorglozow <gzhao408@berkeley.edu>2021-02-11 09:36:20 -0800
committerglozow <gzhao408@berkeley.edu>2021-05-20 21:34:31 +0100
commit42cf8b25df07c45562b7210e0e15c3fd5edb2c11 (patch)
tree4de5e6b16a997889faf3a055f6037b5e5f68ffc9 /src/validation.h
parent710c8ba82953c5fdb7c3c8c9ad6ecf0fd88dface (diff)
downloadbitcoin-42cf8b25df07c45562b7210e0e15c3fd5edb2c11.tar.xz
[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.
Diffstat (limited to 'src/validation.h')
-rw-r--r--src/validation.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/validation.h b/src/validation.h
index 1b50644185..4deaf1830f 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -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