Changeset View
Changeset View
Standalone View
Standalone View
src/validation.h
Show First 20 Lines • Show All 332 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* 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 Consensus::Params ¶ms) | bool LoadBlockIndex(const Consensus::Params ¶ms) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** | /** | ||||
* Update the chain tip based on database information. | |||||
*/ | |||||
bool LoadChainTip(const Config &config) EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
/** | |||||
* Unload database information. | * Unload database information. | ||||
*/ | */ | ||||
void UnloadBlockIndex(); | void UnloadBlockIndex(); | ||||
/** | /** | ||||
* Run an instance of the script checking thread. | * Run an instance of the script checking thread. | ||||
*/ | */ | ||||
void ThreadScriptCheck(int worker_num); | void ThreadScriptCheck(int worker_num); | ||||
▲ Show 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | |||||
class CVerifyDB { | class CVerifyDB { | ||||
public: | public: | ||||
CVerifyDB(); | CVerifyDB(); | ||||
~CVerifyDB(); | ~CVerifyDB(); | ||||
bool VerifyDB(const Config &config, CCoinsView *coinsview, int nCheckLevel, | bool VerifyDB(const Config &config, CCoinsView *coinsview, int nCheckLevel, | ||||
int nCheckDepth); | int nCheckDepth); | ||||
}; | }; | ||||
/** Replay blocks that aren't fully applied to the database. */ | |||||
bool ReplayBlocks(const Consensus::Params ¶ms, CCoinsView *view); | |||||
CBlockIndex *LookupBlockIndex(const BlockHash &hash) | CBlockIndex *LookupBlockIndex(const BlockHash &hash) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** 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); | ||||
▲ Show 20 Lines • Show All 251 Lines • ▼ Show 20 Lines | public: | ||||
* Make the best chain active, in multiple steps. The result is either | * Make the best chain active, in multiple steps. The result is either | ||||
* failure or an activated best chain. pblock is either nullptr or a pointer | * failure or an activated best chain. pblock is either nullptr or a pointer | ||||
* to a block that is already loaded (to avoid loading it again from disk). | * to a block that is already loaded (to avoid loading it again from disk). | ||||
* | * | ||||
* ActivateBestChain is split into steps (see ActivateBestChainStep) so that | * ActivateBestChain is split into steps (see ActivateBestChainStep) so that | ||||
* we avoid holding cs_main for an extended period of time; the length of | * we avoid holding cs_main for an extended period of time; the length of | ||||
* this call may be quite long during reindexing or a substantial reorg. | * this call may be quite long during reindexing or a substantial reorg. | ||||
* | * | ||||
* May not be called with cs_main held. May not be called in a | |||||
* validationinterface callback. | |||||
* | |||||
* @returns true unless a system error occurred | * @returns true unless a system error occurred | ||||
*/ | */ | ||||
bool ActivateBestChain( | bool ActivateBestChain( | ||||
const Config &config, BlockValidationState &state, | const Config &config, BlockValidationState &state, | ||||
std::shared_ptr<const CBlock> pblock = std::shared_ptr<const CBlock>()) | std::shared_ptr<const CBlock> pblock = std::shared_ptr<const CBlock>()) | ||||
LOCKS_EXCLUDED(cs_main); | LOCKS_EXCLUDED(cs_main); | ||||
bool AcceptBlock(const Config &config, | bool AcceptBlock(const Config &config, | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | public: | ||||
template <typename F, typename C, typename AC> | template <typename F, typename C, typename AC> | ||||
void UpdateFlags(CBlockIndex *pindex, CBlockIndex *&pindexReset, F f, | void UpdateFlags(CBlockIndex *pindex, CBlockIndex *&pindexReset, F f, | ||||
C fChild, AC fAncestorWasChanged) | C fChild, AC fAncestorWasChanged) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** Remove parked status from a block and its descendants. */ | /** Remove parked status from a block and its descendants. */ | ||||
void UnparkBlockImpl(CBlockIndex *pindex, bool fClearChildren) | void UnparkBlockImpl(CBlockIndex *pindex, bool fClearChildren) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
bool ReplayBlocks(const Consensus::Params ¶ms, CCoinsView *view); | /** Replay blocks that aren't fully applied to the database. */ | ||||
bool ReplayBlocks(const Consensus::Params ¶ms); | |||||
bool LoadGenesisBlock(const CChainParams &chainparams); | bool LoadGenesisBlock(const CChainParams &chainparams); | ||||
void PruneBlockIndexCandidates(); | void PruneBlockIndexCandidates(); | ||||
void UnloadBlockIndex() EXCLUSIVE_LOCKS_REQUIRED(cs_main); | void UnloadBlockIndex() EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** | /** | ||||
* Check whether we are doing an initial block download (synchronizing from | * Check whether we are doing an initial block download (synchronizing from | ||||
* disk or network) | * disk or network) | ||||
*/ | */ | ||||
bool IsInitialBlockDownload() const; | bool IsInitialBlockDownload() const; | ||||
/** | /** | ||||
* Make various assertions about the state of the block index. | * Make various assertions about the state of the block index. | ||||
* | * | ||||
* By default this only executes fully when using the Regtest chain; see: | * By default this only executes fully when using the Regtest chain; see: | ||||
* fCheckBlockIndex. | * fCheckBlockIndex. | ||||
*/ | */ | ||||
void CheckBlockIndex(const Consensus::Params &consensusParams); | void CheckBlockIndex(const Consensus::Params &consensusParams); | ||||
/** Update the chain tip based on database information, i.e. CoinsTip()'s | |||||
* best block. */ | |||||
bool LoadChainTip(const CChainParams &chainparams) | |||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
private: | private: | ||||
bool ActivateBestChainStep(const Config &config, | bool ActivateBestChainStep(const Config &config, | ||||
BlockValidationState &state, | BlockValidationState &state, | ||||
CBlockIndex *pindexMostWork, | CBlockIndex *pindexMostWork, | ||||
const std::shared_ptr<const CBlock> &pblock, | const std::shared_ptr<const CBlock> &pblock, | ||||
bool &fInvalidFound, ConnectTrace &connectTrace) | bool &fInvalidFound, ConnectTrace &connectTrace) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::g_mempool.cs); | EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::g_mempool.cs); | ||||
bool ConnectTip(const Config &config, BlockValidationState &state, | bool ConnectTip(const Config &config, BlockValidationState &state, | ||||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |