Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 220 Lines • ▼ Show 20 Lines | enum FlushStateMode { | ||||
FLUSH_STATE_ALWAYS | FLUSH_STATE_ALWAYS | ||||
}; | }; | ||||
// See definition for documentation | // See definition for documentation | ||||
static bool FlushStateToDisk(CValidationState &state, FlushStateMode mode, | static bool FlushStateToDisk(CValidationState &state, FlushStateMode mode, | ||||
int nManualPruneHeight = 0); | int nManualPruneHeight = 0); | ||||
static void FindFilesToPruneManual(std::set<int> &setFilesToPrune, | static void FindFilesToPruneManual(std::set<int> &setFilesToPrune, | ||||
int nManualPruneHeight); | int nManualPruneHeight); | ||||
static bool CheckInputs(const CTransaction &tx, CValidationState &state, | |||||
const CCoinsViewCache &view, bool fScriptChecks, | |||||
uint32_t flags, bool sigCacheStore, | |||||
bool scriptCacheStore, | |||||
const PrecomputedTransactionData &txdata, | |||||
std::vector<CScriptCheck> *pvChecks = nullptr); | |||||
static uint32_t GetBlockScriptFlags(const CBlockIndex *pindex, | static uint32_t GetBlockScriptFlags(const CBlockIndex *pindex, | ||||
const Config &config); | const Config &config); | ||||
static bool IsFinalTx(const CTransaction &tx, int nBlockHeight, | static bool IsFinalTx(const CTransaction &tx, int nBlockHeight, | ||||
int64_t nBlockTime) { | int64_t nBlockTime) { | ||||
if (tx.nLockTime == 0) { | if (tx.nLockTime == 0) { | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,166 Lines • ▼ Show 20 Lines | bool CheckTxInputs(const CTransaction &tx, CValidationState &state, | ||||
if (!MoneyRange(nFees)) { | if (!MoneyRange(nFees)) { | ||||
return state.DoS(100, false, REJECT_INVALID, "bad-txns-fee-outofrange"); | return state.DoS(100, false, REJECT_INVALID, "bad-txns-fee-outofrange"); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
} // namespace Consensus | } // namespace Consensus | ||||
/** | bool CheckInputs(const CTransaction &tx, CValidationState &state, | ||||
* Check whether all inputs of this transaction are valid (no double spends, | |||||
* scripts & sigs, amounts). This does not modify the UTXO set. | |||||
* | |||||
* If pvChecks is not nullptr, script checks are pushed onto it instead of being | |||||
* performed inline. Any script checks which are not necessary (eg due to script | |||||
* execution cache hits) are, obviously, not pushed onto pvChecks/run. | |||||
* | |||||
* Setting sigCacheStore/scriptCacheStore to false will remove elements from the | |||||
* corresponding cache which are matched. This is useful for checking blocks | |||||
* where we will likely never need the cache entry again. | |||||
*/ | |||||
static bool CheckInputs(const CTransaction &tx, CValidationState &state, | |||||
const CCoinsViewCache &inputs, bool fScriptChecks, | const CCoinsViewCache &inputs, bool fScriptChecks, | ||||
uint32_t flags, bool sigCacheStore, | uint32_t flags, bool sigCacheStore, bool scriptCacheStore, | ||||
bool scriptCacheStore, | |||||
const PrecomputedTransactionData &txdata, | const PrecomputedTransactionData &txdata, | ||||
std::vector<CScriptCheck> *pvChecks) { | std::vector<CScriptCheck> *pvChecks) { | ||||
assert(!tx.IsCoinBase()); | assert(!tx.IsCoinBase()); | ||||
if (!Consensus::CheckTxInputs(tx, state, inputs, GetSpendHeight(inputs))) { | if (!Consensus::CheckTxInputs(tx, state, inputs, GetSpendHeight(inputs))) { | ||||
return false; | return false; | ||||
} | } | ||||
if (pvChecks) { | if (pvChecks) { | ||||
pvChecks->reserve(tx.vin.size()); | pvChecks->reserve(tx.vin.size()); | ||||
▲ Show 20 Lines • Show All 3,622 Lines • Show Last 20 Lines |