mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
[doc] for CheckInputsFromMempoolAndCache
This commit is contained in:
parent
85cc6bed64
commit
2f463f57e3
1 changed files with 17 additions and 8 deletions
|
@ -404,10 +404,16 @@ static void UpdateMempoolForReorg(CTxMemPool& mempool, DisconnectedBlockTransact
|
|||
LimitMempoolSize(mempool, gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, std::chrono::hours{gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY)});
|
||||
}
|
||||
|
||||
// Used to avoid mempool polluting consensus critical paths if CCoinsViewMempool
|
||||
// were somehow broken and returning the wrong scriptPubKeys
|
||||
static bool CheckInputsFromMempoolAndCache(const CTransaction& tx, TxValidationState& state, const CCoinsViewCache& view, const CTxMemPool& pool,
|
||||
unsigned int flags, PrecomputedTransactionData& txdata) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs) {
|
||||
/**
|
||||
* Checks to avoid mempool polluting consensus critical paths since cached
|
||||
* signature and script validity results will be reused if we validate this
|
||||
* transaction again during block validation.
|
||||
* */
|
||||
static bool CheckInputsFromMempoolAndCache(const CTransaction& tx, TxValidationState& state,
|
||||
const CCoinsViewCache& view, const CTxMemPool& pool,
|
||||
unsigned int flags, PrecomputedTransactionData& txdata)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
AssertLockHeld(pool.cs);
|
||||
|
||||
|
@ -420,16 +426,19 @@ static bool CheckInputsFromMempoolAndCache(const CTransaction& tx, TxValidationS
|
|||
Assume(!coin.IsSpent());
|
||||
if (coin.IsSpent()) return false;
|
||||
|
||||
// Check equivalence for available inputs.
|
||||
// If the Coin is available, there are 2 possibilities:
|
||||
// it is available in our current ChainstateActive UTXO set,
|
||||
// or it's a UTXO provided by a transaction in our mempool.
|
||||
// Ensure the scriptPubKeys in Coins from CoinsView are correct.
|
||||
const CTransactionRef& txFrom = pool.get(txin.prevout.hash);
|
||||
if (txFrom) {
|
||||
assert(txFrom->GetHash() == txin.prevout.hash);
|
||||
assert(txFrom->vout.size() > txin.prevout.n);
|
||||
assert(txFrom->vout[txin.prevout.n] == coin.out);
|
||||
} else {
|
||||
const Coin& coinFromDisk = ::ChainstateActive().CoinsTip().AccessCoin(txin.prevout);
|
||||
assert(!coinFromDisk.IsSpent());
|
||||
assert(coinFromDisk.out == coin.out);
|
||||
const Coin& coinFromUTXOSet = ::ChainstateActive().CoinsTip().AccessCoin(txin.prevout);
|
||||
assert(!coinFromUTXOSet.IsSpent());
|
||||
assert(coinFromUTXOSet.out == coin.out);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue