Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | enum FlushStateMode { | ||||
FLUSH_STATE_IF_NEEDED, | FLUSH_STATE_IF_NEEDED, | ||||
FLUSH_STATE_PERIODIC, | FLUSH_STATE_PERIODIC, | ||||
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); | ||||
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 cacheStore, | |||||
const PrecomputedTransactionData &txdata, | |||||
std::vector<CScriptCheck> *pvChecks = nullptr); | |||||
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; | ||||
} | } | ||||
int64_t lockTime = tx.nLockTime; | int64_t lockTime = tx.nLockTime; | ||||
▲ Show 20 Lines • Show All 1,095 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. | |||||
*/ | |||||
static bool CheckInputs(const CTransaction &tx, CValidationState &state, | |||||
const CCoinsViewCache &inputs, bool fScriptChecks, | const CCoinsViewCache &inputs, bool fScriptChecks, | ||||
uint32_t flags, bool cacheStore, | uint32_t flags, bool cacheStore, | ||||
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 2,362 Lines • ▼ Show 20 Lines | for (std::set<int>::iterator it = setFilesToPrune.begin(); | ||||
LogPrintf("Prune: %s deleted blk/rev (%05u)\n", __func__, *it); | LogPrintf("Prune: %s deleted blk/rev (%05u)\n", __func__, *it); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Calculate the block/rev files to delete based on height specified by user | * Calculate the block/rev files to delete based on height specified by user | ||||
* with RPC command pruneblockchain. | * with RPC command pruneblockchain. | ||||
*/ | */ | ||||
void FindFilesToPruneManual(std::set<int> &setFilesToPrune, | static void FindFilesToPruneManual(std::set<int> &setFilesToPrune, | ||||
int nManualPruneHeight) { | int nManualPruneHeight) { | ||||
assert(fPruneMode && nManualPruneHeight > 0); | assert(fPruneMode && nManualPruneHeight > 0); | ||||
LOCK2(cs_main, cs_LastBlockFile); | LOCK2(cs_main, cs_LastBlockFile); | ||||
if (chainActive.Tip() == nullptr) { | if (chainActive.Tip() == nullptr) { | ||||
return; | return; | ||||
} | } | ||||
// last block to prune is the lesser of (user-specified height, | // last block to prune is the lesser of (user-specified height, | ||||
▲ Show 20 Lines • Show All 1,209 Lines • Show Last 20 Lines |