Rename `CheckInputs` to `ContextualCheckInputs` since it relies on a global variable
and assumes calling conditions.
This commit is contained in:
parent
47e6645005
commit
10df6fb3df
|
@ -1219,7 +1219,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||||
|
|
||||||
// Check against previous transactions
|
// Check against previous transactions
|
||||||
// This is done last to help prevent CPU exhaustion denial-of-service attacks.
|
// This is done last to help prevent CPU exhaustion denial-of-service attacks.
|
||||||
if (!CheckInputs(tx, state, view, true, STANDARD_SCRIPT_VERIFY_FLAGS, true))
|
if (!ContextualCheckInputs(tx, state, view, true, STANDARD_SCRIPT_VERIFY_FLAGS, true))
|
||||||
{
|
{
|
||||||
return error("AcceptToMemoryPool: ConnectInputs failed %s", hash.ToString());
|
return error("AcceptToMemoryPool: ConnectInputs failed %s", hash.ToString());
|
||||||
}
|
}
|
||||||
|
@ -1233,7 +1233,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||||
// There is a similar check in CreateNewBlock() to prevent creating
|
// There is a similar check in CreateNewBlock() to prevent creating
|
||||||
// invalid blocks, however allowing such transactions into the mempool
|
// invalid blocks, however allowing such transactions into the mempool
|
||||||
// can be exploited as a DoS attack.
|
// can be exploited as a DoS attack.
|
||||||
if (!CheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true))
|
if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true))
|
||||||
{
|
{
|
||||||
return error("AcceptToMemoryPool: BUG! PLEASE REPORT THIS! ConnectInputs failed against MANDATORY but not STANDARD flags %s", hash.ToString());
|
return error("AcceptToMemoryPool: BUG! PLEASE REPORT THIS! ConnectInputs failed against MANDATORY but not STANDARD flags %s", hash.ToString());
|
||||||
}
|
}
|
||||||
|
@ -1604,7 +1604,7 @@ bool CScriptCheck::operator()() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, bool cacheStore, std::vector<CScriptCheck> *pvChecks)
|
bool ContextualCheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, bool cacheStore, std::vector<CScriptCheck> *pvChecks)
|
||||||
{
|
{
|
||||||
if (!tx.IsCoinBase())
|
if (!tx.IsCoinBase())
|
||||||
{
|
{
|
||||||
|
@ -2128,7 +2128,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||||
nFees += view.GetValueIn(tx)-tx.GetValueOut();
|
nFees += view.GetValueIn(tx)-tx.GetValueOut();
|
||||||
|
|
||||||
std::vector<CScriptCheck> vChecks;
|
std::vector<CScriptCheck> vChecks;
|
||||||
if (!CheckInputs(tx, state, view, fScriptChecks, flags, false, nScriptCheckThreads ? &vChecks : NULL))
|
if (!ContextualCheckInputs(tx, state, view, fScriptChecks, flags, false, nScriptCheckThreads ? &vChecks : NULL))
|
||||||
return false;
|
return false;
|
||||||
control.Add(vChecks);
|
control.Add(vChecks);
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,7 +317,7 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& ma
|
||||||
* This does not modify the UTXO set. If pvChecks is not NULL, script checks are pushed onto it
|
* This does not modify the UTXO set. If pvChecks is not NULL, script checks are pushed onto it
|
||||||
* instead of being performed inline.
|
* instead of being performed inline.
|
||||||
*/
|
*/
|
||||||
bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsViewCache &view, bool fScriptChecks,
|
bool ContextualCheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsViewCache &view, bool fScriptChecks,
|
||||||
unsigned int flags, bool cacheStore, std::vector<CScriptCheck> *pvChecks = NULL);
|
unsigned int flags, bool cacheStore, std::vector<CScriptCheck> *pvChecks = NULL);
|
||||||
|
|
||||||
/** Apply the effects of this transaction on the UTXO set represented by view */
|
/** Apply the effects of this transaction on the UTXO set represented by view */
|
||||||
|
|
|
@ -282,7 +282,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||||
// policy here, but we still have to ensure that the block we
|
// policy here, but we still have to ensure that the block we
|
||||||
// create only contains transactions that are valid in new blocks.
|
// create only contains transactions that are valid in new blocks.
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
if (!CheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true))
|
if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
UpdateCoins(tx, state, view, nHeight);
|
UpdateCoins(tx, state, view, nHeight);
|
||||||
|
|
|
@ -327,7 +327,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
|
||||||
waitingOnDependants.push_back(&it->second);
|
waitingOnDependants.push_back(&it->second);
|
||||||
else {
|
else {
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
assert(CheckInputs(tx, state, mempoolDuplicate, false, 0, false, NULL));
|
assert(ContextualCheckInputs(tx, state, mempoolDuplicate, false, 0, false, NULL));
|
||||||
UpdateCoins(tx, state, mempoolDuplicate, 1000000);
|
UpdateCoins(tx, state, mempoolDuplicate, 1000000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -341,7 +341,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
|
||||||
stepsSinceLastRemove++;
|
stepsSinceLastRemove++;
|
||||||
assert(stepsSinceLastRemove < waitingOnDependants.size());
|
assert(stepsSinceLastRemove < waitingOnDependants.size());
|
||||||
} else {
|
} else {
|
||||||
assert(CheckInputs(entry->GetTx(), state, mempoolDuplicate, false, 0, false, NULL));
|
assert(ContextualCheckInputs(entry->GetTx(), state, mempoolDuplicate, false, 0, false, NULL));
|
||||||
UpdateCoins(entry->GetTx(), state, mempoolDuplicate, 1000000);
|
UpdateCoins(entry->GetTx(), state, mempoolDuplicate, 1000000);
|
||||||
stepsSinceLastRemove = 0;
|
stepsSinceLastRemove = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue