Changeset View
Changeset View
Standalone View
Standalone View
src/validation.h
Show First 20 Lines • Show All 288 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024; | static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024; | ||||
class BlockValidationOptions { | class BlockValidationOptions { | ||||
private: | private: | ||||
bool checkPoW : 1; | bool checkPoW : 1; | ||||
bool checkMerkleRoot : 1; | bool checkMerkleRoot : 1; | ||||
uint64_t excessiveBlockSize; | |||||
public: | public: | ||||
// Do full validation by default | // Do full validation by default | ||||
BlockValidationOptions() : checkPoW(true), checkMerkleRoot(true) {} | BlockValidationOptions(const Config &config); | ||||
BlockValidationOptions(bool checkPoWIn, bool checkMerkleRootIn) | |||||
: checkPoW(checkPoWIn), checkMerkleRoot(checkMerkleRootIn) {} | BlockValidationOptions withCheckPoW(bool _checkPoW = true) const { | ||||
BlockValidationOptions ret = *this; | |||||
ret.checkPoW = _checkPoW; | |||||
return ret; | |||||
} | |||||
BlockValidationOptions | |||||
withCheckMerkleRoot(bool _checkMerkleRoot = true) const { | |||||
BlockValidationOptions ret = *this; | |||||
ret.checkMerkleRoot = _checkMerkleRoot; | |||||
return ret; | |||||
} | |||||
bool shouldValidatePoW() const { return checkPoW; } | bool shouldValidatePoW() const { return checkPoW; } | ||||
bool shouldValidateMerkleRoot() const { return checkMerkleRoot; } | bool shouldValidateMerkleRoot() const { return checkMerkleRoot; } | ||||
uint64_t getExcessiveBlockSize() const { return excessiveBlockSize; } | |||||
}; | }; | ||||
/** | /** | ||||
* Process an incoming block. This only returns after the best known valid | * Process an incoming block. This only returns after the best known valid | ||||
* block is made active. Note that it does not, however, guarantee that the | * block is made active. Note that it does not, however, guarantee that the | ||||
* specific block passed to it has been checked for validity! | * specific block passed to it has been checked for validity! | ||||
* | * | ||||
* If you want to *possibly* get feedback on whether pblock is valid, you must | * If you want to *possibly* get feedback on whether pblock is valid, you must | ||||
▲ Show 20 Lines • Show All 255 Lines • ▼ Show 20 Lines | |||||
/** Functions for validating blocks and updating the block tree */ | /** Functions for validating blocks and updating the block tree */ | ||||
/** | /** | ||||
* Context-independent validity checks. | * Context-independent validity checks. | ||||
* | * | ||||
* Returns true if the provided block is valid (has valid header, | * Returns true if the provided block is valid (has valid header, | ||||
* transactions are valid, block is a valid size, etc.) | * transactions are valid, block is a valid size, etc.) | ||||
*/ | */ | ||||
bool CheckBlock( | bool CheckBlock(const Config &Config, const CBlock &block, | ||||
const Config &Config, const CBlock &block, CValidationState &state, | CValidationState &state, | ||||
BlockValidationOptions validationOptions = BlockValidationOptions()); | BlockValidationOptions validationOptions); | ||||
/** | /** | ||||
* This is a variant of ContextualCheckTransaction which computes the contextual | * This is a variant of ContextualCheckTransaction which computes the contextual | ||||
* check for a transaction based on the chain tip. | * check for a transaction based on the chain tip. | ||||
* | * | ||||
* See consensus/consensus.h for flag definitions. | * See consensus/consensus.h for flag definitions. | ||||
*/ | */ | ||||
bool ContextualCheckTransactionForCurrentBlock(const Consensus::Params ¶ms, | bool ContextualCheckTransactionForCurrentBlock(const Consensus::Params ¶ms, | ||||
const CTransaction &tx, | const CTransaction &tx, | ||||
CValidationState &state, | CValidationState &state, | ||||
int flags = -1); | int flags = -1); | ||||
/** | /** | ||||
* Check a block is completely valid from start to finish (only works on top of | * Check a block is completely valid from start to finish (only works on top of | ||||
* our current best block, with cs_main held) | * our current best block, with cs_main held) | ||||
*/ | */ | ||||
bool TestBlockValidity( | bool TestBlockValidity(const Config &config, CValidationState &state, | ||||
const Config &config, CValidationState &state, const CBlock &block, | const CBlock &block, CBlockIndex *pindexPrev, | ||||
CBlockIndex *pindexPrev, | BlockValidationOptions validationOptions); | ||||
BlockValidationOptions validationOptions = BlockValidationOptions()); | |||||
/** | /** | ||||
* When there are blocks in the active chain with missing data, rewind the | * When there are blocks in the active chain with missing data, rewind the | ||||
* chainstate and remove them from the block index. | * chainstate and remove them from the block index. | ||||
*/ | */ | ||||
bool RewindBlockIndex(const Config &config); | bool RewindBlockIndex(const Config &config); | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines |