mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Merge bitcoin/bitcoin#23897: refactor: Move calculation logic out from CheckSequenceLocksAtTip()
75db62ba4crefactor: Move calculation logic out from `CheckSequenceLocksAtTip()` (Hennadii Stepanov)3bc434f459refactor: Add `CalculateLockPointsAtTip()` function (Hennadii Stepanov) Pull request description: This PR is follow up for bitcoin/bitcoin#22677 and bitcoin/bitcoin#23683. On master (013daed9ac) it is not obvious that `CheckSequenceLocksAtTip()` function can modify its `LockPoints* lp` parameter which leads to https://github.com/bitcoin/bitcoin/pull/22677#discussion_r762040101. This PR: - separates the lockpoint calculate logic from `CheckSequenceLocksAtTip()` function into a new `CalculateLockPointsAtTip()` one - cleans up the `CheckSequenceLocksAtTip()` function interface - makes code easier to reason about (hopefully) ACKs for top commit: achow101: ACK75db62ba4cstickies-v: re-ACK75db62bTree-SHA512: 072c3fd9cd1e1b0e0bfc8960a67b01c80a9f16d6778f374b6944ade03a020415ce8b8ab2593b0f5e787059c8cf90af798290b4c826785d41955092f6e12e7486
This commit is contained in:
@@ -267,27 +267,39 @@ PackageMempoolAcceptResult ProcessNewPackage(Chainstate& active_chainstate, CTxM
|
||||
bool CheckFinalTxAtTip(const CBlockIndex& active_chain_tip, const CTransaction& tx) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Calculate LockPoints required to check if transaction will be BIP68 final in the next block
|
||||
* to be created on top of tip.
|
||||
*
|
||||
* @param[in] tip Chain tip for which tx sequence locks are calculated. 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. For example, it can be a CCoinsViewCache
|
||||
* that isn't connected to anything but contains all the relevant
|
||||
* coins, or a CCoinsViewMemPool that is connected to the
|
||||
* mempool and chainstate UTXO set. In the latter case, the caller is
|
||||
* responsible for holding the appropriate locks to ensure that
|
||||
* mempool and chainstate UTXO set. In the latter case, the caller
|
||||
* is responsible for holding the appropriate locks to ensure that
|
||||
* calls to GetCoin() return correct coins.
|
||||
* @param[in] tx The transaction being evaluated.
|
||||
*
|
||||
* @returns The resulting height and time calculated and the hash of the block needed for
|
||||
* calculation, or std::nullopt if there is an error.
|
||||
*/
|
||||
std::optional<LockPoints> CalculateLockPointsAtTip(
|
||||
CBlockIndex* tip,
|
||||
const CCoinsView& coins_view,
|
||||
const CTransaction& tx);
|
||||
|
||||
/**
|
||||
* 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] lock_points LockPoints containing the height and time at which this
|
||||
* transaction is final.
|
||||
* 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.
|
||||
* The LockPoints should not be considered valid if CheckSequenceLocksAtTip returns false.
|
||||
*/
|
||||
bool CheckSequenceLocksAtTip(CBlockIndex* tip,
|
||||
const CCoinsView& coins_view,
|
||||
const CTransaction& tx,
|
||||
LockPoints* lp = nullptr,
|
||||
bool useExistingLockPoints = false);
|
||||
const LockPoints& lock_points);
|
||||
|
||||
/**
|
||||
* Closure representing one script verification
|
||||
|
||||
Reference in New Issue
Block a user