mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-02 15:32:34 +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,
|
static bool CheckInputsFromMempoolAndCache(const CTransaction& tx, TxValidationState& state,
|
||||||
const CCoinsViewCache& view, const CTxMemPool& pool,
|
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)
|
EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
@ -440,7 +440,8 @@ static bool CheckInputsFromMempoolAndCache(const CTransaction& tx, TxValidationS
|
|||||||
assert(txFrom->vout.size() > txin.prevout.n);
|
assert(txFrom->vout.size() > txin.prevout.n);
|
||||||
assert(txFrom->vout[txin.prevout.n] == coin.out);
|
assert(txFrom->vout[txin.prevout.n] == coin.out);
|
||||||
} else {
|
} 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.IsSpent());
|
||||||
assert(coinFromUTXOSet.out == coin.out);
|
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
|
// invalid blocks (using TestBlockValidity), however allowing such
|
||||||
// transactions into the mempool can be exploited as a DoS attack.
|
// transactions into the mempool can be exploited as a DoS attack.
|
||||||
unsigned int currentBlockScriptVerifyFlags = GetBlockScriptFlags(::ChainActive().Tip(), chainparams.GetConsensus());
|
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",
|
return error("%s: BUG! PLEASE REPORT THIS! CheckInputScripts failed against latest-block but not STANDARD flags %s, %s",
|
||||||
__func__, hash.ToString(), state.ToString());
|
__func__, hash.ToString(), state.ToString());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user