mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-09 20:59:38 +02:00
validation: Pass in coins tip to CheckInputsFromMempoolAndCache
This commit is contained in:
parent
73a6d2b7be
commit
252b489c9f
@ -415,7 +415,7 @@ static void UpdateMempoolForReorg(CTxMemPool& mempool, DisconnectedBlockTransact
|
||||
* */
|
||||
static bool CheckInputsFromMempoolAndCache(const CTransaction& tx, TxValidationState& state,
|
||||
const CCoinsViewCache& view, const CTxMemPool& pool,
|
||||
unsigned int flags, PrecomputedTransactionData& txdata)
|
||||
unsigned int flags, PrecomputedTransactionData& txdata, CCoinsViewCache& coins_tip)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
@ -440,7 +440,8 @@ static bool CheckInputsFromMempoolAndCache(const CTransaction& tx, TxValidationS
|
||||
assert(txFrom->vout.size() > txin.prevout.n);
|
||||
assert(txFrom->vout[txin.prevout.n] == coin.out);
|
||||
} else {
|
||||
const Coin& coinFromUTXOSet = ::ChainstateActive().CoinsTip().AccessCoin(txin.prevout);
|
||||
assert(std::addressof(::ChainstateActive().CoinsTip()) == std::addressof(coins_tip));
|
||||
const Coin& coinFromUTXOSet = coins_tip.AccessCoin(txin.prevout);
|
||||
assert(!coinFromUTXOSet.IsSpent());
|
||||
assert(coinFromUTXOSet.out == coin.out);
|
||||
}
|
||||
@ -970,7 +971,7 @@ bool MemPoolAccept::ConsensusScriptChecks(const ATMPArgs& args, Workspace& ws, P
|
||||
// invalid blocks (using TestBlockValidity), however allowing such
|
||||
// transactions into the mempool can be exploited as a DoS attack.
|
||||
unsigned int currentBlockScriptVerifyFlags = GetBlockScriptFlags(::ChainActive().Tip(), chainparams.GetConsensus());
|
||||
if (!CheckInputsFromMempoolAndCache(tx, state, m_view, m_pool, currentBlockScriptVerifyFlags, txdata)) {
|
||||
if (!CheckInputsFromMempoolAndCache(tx, state, m_view, m_pool, currentBlockScriptVerifyFlags, txdata, ::ChainstateActive().CoinsTip())) {
|
||||
return error("%s: BUG! PLEASE REPORT THIS! CheckInputScripts failed against latest-block but not STANDARD flags %s, %s",
|
||||
__func__, hash.ToString(), state.ToString());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user