Changeset View
Changeset View
Standalone View
Standalone View
src/validation.h
Show First 20 Lines • Show All 327 Lines • ▼ Show 20 Lines | |||||
* | * | ||||
* 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 | ||||
* install a CValidationInterface (see validationinterface.h) - this will have | * install a CValidationInterface (see validationinterface.h) - this will have | ||||
* its BlockChecked method called whenever *any* block completes validation. | * its BlockChecked method called whenever *any* block completes validation. | ||||
* | * | ||||
* Note that we guarantee that either the proof-of-work is valid on pblock, or | * Note that we guarantee that either the proof-of-work is valid on pblock, or | ||||
* (and possibly also) BlockChecked will have been called. | * (and possibly also) BlockChecked will have been called. | ||||
* | * | ||||
* May not be called with cs_main held. May not be called in a | * May not be called in a validationinterface callback. | ||||
* validationinterface callback. | |||||
* | * | ||||
* @param[in] config The global config. | * @param[in] config The global config. | ||||
* @param[in] pblock The block we want to process. | * @param[in] pblock The block we want to process. | ||||
* @param[in] fForceProcessing Process this block even if unrequested; used | * @param[in] fForceProcessing Process this block even if unrequested; used | ||||
* for non-network block sources and whitelisted peers. | * for non-network block sources and whitelisted peers. | ||||
* @param[out] fNewBlock A boolean which is set to indicate if the block was | * @param[out] fNewBlock A boolean which is set to indicate if the block was | ||||
* first received via this call. | * first received via this call. | ||||
* @return True if the block is accepted as a valid block. | * @return True if the block is accepted as a valid block. | ||||
*/ | */ | ||||
bool ProcessNewBlock(const Config &config, | bool ProcessNewBlock(const Config &config, | ||||
const std::shared_ptr<const CBlock> pblock, | const std::shared_ptr<const CBlock> pblock, | ||||
bool fForceProcessing, bool *fNewBlock); | bool fForceProcessing, bool *fNewBlock) | ||||
LOCKS_EXCLUDED(cs_main); | |||||
/** | /** | ||||
* Process incoming block headers. | * Process incoming block headers. | ||||
* | * | ||||
* May not be called with cs_main held. May not be called in a | * May not be called in a validationinterface callback. | ||||
* validationinterface callback. | |||||
* | * | ||||
* @param[in] config The config. | * @param[in] config The config. | ||||
* @param[in] block The block headers themselves. | * @param[in] block The block headers themselves. | ||||
* @param[out] state This may be set to an Error state if any error | * @param[out] state This may be set to an Error state if any error | ||||
* occurred processing them. | * occurred processing them. | ||||
* @param[out] ppindex If set, the pointer will be set to point to the | * @param[out] ppindex If set, the pointer will be set to point to the | ||||
* last new block index object for the given headers. | * last new block index object for the given headers. | ||||
* @param[out] first_invalid First header that fails validation, if one exists. | * @param[out] first_invalid First header that fails validation, if one exists. | ||||
* @return True if block headers were accepted as valid. | * @return True if block headers were accepted as valid. | ||||
*/ | */ | ||||
bool ProcessNewBlockHeaders(const Config &config, | bool ProcessNewBlockHeaders(const Config &config, | ||||
const std::vector<CBlockHeader> &block, | const std::vector<CBlockHeader> &block, | ||||
CValidationState &state, | CValidationState &state, | ||||
const CBlockIndex **ppindex = nullptr, | const CBlockIndex **ppindex = nullptr, | ||||
CBlockHeader *first_invalid = nullptr); | CBlockHeader *first_invalid = nullptr) | ||||
LOCKS_EXCLUDED(cs_main); | |||||
/** | /** | ||||
* Open a block file (blk?????.dat). | * Open a block file (blk?????.dat). | ||||
*/ | */ | ||||
FILE *OpenBlockFile(const FlatFilePos &pos, bool fReadOnly = false); | FILE *OpenBlockFile(const FlatFilePos &pos, bool fReadOnly = false); | ||||
/** | /** | ||||
* Translation to a filesystem path. | * Translation to a filesystem path. | ||||
Show All 11 Lines | |||||
* disk. | * disk. | ||||
*/ | */ | ||||
bool LoadGenesisBlock(const CChainParams &chainparams); | bool LoadGenesisBlock(const CChainParams &chainparams); | ||||
/** | /** | ||||
* Load the block tree and coins database from disk, initializing state if we're | * Load the block tree and coins database from disk, initializing state if we're | ||||
* running with -reindex. | * running with -reindex. | ||||
*/ | */ | ||||
bool LoadBlockIndex(const Config &config); | bool LoadBlockIndex(const Config &config) EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** | /** | ||||
* Update the chain tip based on database information. | * Update the chain tip based on database information. | ||||
*/ | */ | ||||
bool LoadChainTip(const Config &config) EXCLUSIVE_LOCKS_REQUIRED(cs_main); | bool LoadChainTip(const Config &config) EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** | /** | ||||
* Unload database information. | * Unload database information. | ||||
▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
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) | ||||
*/ | */ | ||||
bool TestBlockValidity(CValidationState &state, const CChainParams ¶ms, | bool TestBlockValidity(CValidationState &state, const CChainParams ¶ms, | ||||
const CBlock &block, CBlockIndex *pindexPrev, | const CBlock &block, CBlockIndex *pindexPrev, | ||||
BlockValidationOptions validationOptions); | BlockValidationOptions validationOptions) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
/** | /** | ||||
* 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 All 14 Lines | |||||
/** Find the last common block between the parameter chain and a locator. */ | /** Find the last common block between the parameter chain and a locator. */ | ||||
CBlockIndex *FindForkInGlobalIndex(const CChain &chain, | CBlockIndex *FindForkInGlobalIndex(const CChain &chain, | ||||
const CBlockLocator &locator) | const CBlockLocator &locator) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** | /** | ||||
* Mark a block as precious and reorganize. | * Mark a block as precious and reorganize. | ||||
* | * | ||||
* May not be called with cs_main held. May not be called in a | * May not be called in a validationinterface callback. | ||||
* validationinterface callback. | |||||
*/ | */ | ||||
bool PreciousBlock(const Config &config, CValidationState &state, | bool PreciousBlock(const Config &config, CValidationState &state, | ||||
CBlockIndex *pindex); | CBlockIndex *pindex) LOCKS_EXCLUDED(cs_main); | ||||
/** | /** | ||||
* Mark a block as finalized. | * Mark a block as finalized. | ||||
* A finalized block can not be reorged in any way. | * A finalized block can not be reorged in any way. | ||||
*/ | */ | ||||
bool FinalizeBlockAndInvalidate(const Config &config, CValidationState &state, | bool FinalizeBlockAndInvalidate(const Config &config, CValidationState &state, | ||||
CBlockIndex *pindex); | CBlockIndex *pindex); | ||||
/** Mark a block as invalid. */ | /** Mark a block as invalid. */ | ||||
bool InvalidateBlock(const Config &config, CValidationState &state, | bool InvalidateBlock(const Config &config, CValidationState &state, | ||||
CBlockIndex *pindex); | CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** Park a block. */ | /** Park a block. */ | ||||
bool ParkBlock(const Config &config, CValidationState &state, | bool ParkBlock(const Config &config, CValidationState &state, | ||||
CBlockIndex *pindex); | CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** Remove invalidity status from a block and its descendants. */ | /** Remove invalidity status from a block and its descendants. */ | ||||
void ResetBlockFailureFlags(CBlockIndex *pindex); | void ResetBlockFailureFlags(CBlockIndex *pindex) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
/** Remove parked status from a block and its descendants. */ | /** Remove parked status from a block and its descendants. */ | ||||
void UnparkBlockAndChildren(CBlockIndex *pindex); | void UnparkBlockAndChildren(CBlockIndex *pindex) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
/** Remove parked status from a block. */ | /** Remove parked status from a block. */ | ||||
void UnparkBlock(CBlockIndex *pindex); | void UnparkBlock(CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** | /** | ||||
* Retrieve the topmost finalized block. | * Retrieve the topmost finalized block. | ||||
*/ | */ | ||||
const CBlockIndex *GetFinalizedBlock(); | const CBlockIndex *GetFinalizedBlock() EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** | /** | ||||
* Checks if a block is finalized. | * Checks if a block is finalized. | ||||
*/ | */ | ||||
bool IsBlockFinalized(const CBlockIndex *pindex); | bool IsBlockFinalized(const CBlockIndex *pindex) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
/** The currently-connected chain of blocks (protected by cs_main). */ | /** The currently-connected chain of blocks (protected by cs_main). */ | ||||
extern CChain &chainActive; | extern CChain &chainActive; | ||||
/** | /** | ||||
* Global variable that points to the coins database (protected by cs_main) | * Global variable that points to the coins database (protected by cs_main) | ||||
*/ | */ | ||||
extern std::unique_ptr<CCoinsViewDB> pcoinsdbview; | extern std::unique_ptr<CCoinsViewDB> pcoinsdbview; | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |