Changeset View
Changeset View
Standalone View
Standalone View
src/validation.h
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | |||||
/** Current sync state passed to tip changed callbacks. */ | /** Current sync state passed to tip changed callbacks. */ | ||||
enum class SynchronizationState { INIT_REINDEX, INIT_DOWNLOAD, POST_INIT }; | enum class SynchronizationState { INIT_REINDEX, INIT_DOWNLOAD, POST_INIT }; | ||||
extern GlobalMutex g_best_block_mutex; | extern GlobalMutex g_best_block_mutex; | ||||
extern std::condition_variable g_best_block_cv; | extern std::condition_variable g_best_block_cv; | ||||
/** Used to notify getblocktemplate RPC of new tips. */ | /** Used to notify getblocktemplate RPC of new tips. */ | ||||
extern uint256 g_best_block; | extern uint256 g_best_block; | ||||
extern bool fCheckBlockIndex; | |||||
/** Documentation for argument 'checklevel'. */ | /** Documentation for argument 'checklevel'. */ | ||||
extern const std::vector<std::string> CHECKLEVEL_DOC; | extern const std::vector<std::string> CHECKLEVEL_DOC; | ||||
class BlockValidationOptions { | class BlockValidationOptions { | ||||
private: | private: | ||||
uint64_t excessiveBlockSize; | uint64_t excessiveBlockSize; | ||||
bool checkPoW : 1; | bool checkPoW : 1; | ||||
▲ Show 20 Lines • Show All 745 Lines • ▼ Show 20 Lines | public: | ||||
* validationinterface callback. | * validationinterface callback. | ||||
* | * | ||||
* Note that if this is called while a snapshot chainstate is active, and if | * Note that if this is called while a snapshot chainstate is active, and if | ||||
* it is called on a background chainstate whose tip has reached the base | * it is called on a background chainstate whose tip has reached the base | ||||
* block of the snapshot, its execution will take *MINUTES* while it hashes | * block of the snapshot, its execution will take *MINUTES* while it hashes | ||||
* the background UTXO set to verify the assumeutxo value the snapshot was | * the background UTXO set to verify the assumeutxo value the snapshot was | ||||
* activated with. `cs_main` will be held during this time. | * activated with. `cs_main` will be held during this time. | ||||
* | * | ||||
* @param[in] skip_checkblockindex (optional) | |||||
* If true, skip calling CheckBlockIndex even if -checkblockindex is | |||||
* true. If false (default behavior), respect the -checkblockindex arg. | |||||
* This is used in tests when we need to skip the checks only | |||||
* temporarily, and resume normal behavior later. | |||||
* @returns true unless a system error occurred | * @returns true unless a system error occurred | ||||
*/ | */ | ||||
bool ActivateBestChain(BlockValidationState &state, | bool ActivateBestChain(BlockValidationState &state, | ||||
std::shared_ptr<const CBlock> pblock = nullptr) | std::shared_ptr<const CBlock> pblock = nullptr, | ||||
bool skip_checkblockindex = false) | |||||
EXCLUSIVE_LOCKS_REQUIRED(!m_chainstate_mutex, | EXCLUSIVE_LOCKS_REQUIRED(!m_chainstate_mutex, | ||||
!cs_avalancheFinalizedBlockIndex) | !cs_avalancheFinalizedBlockIndex) | ||||
LOCKS_EXCLUDED(cs_main); | LOCKS_EXCLUDED(cs_main); | ||||
bool AcceptBlock(const std::shared_ptr<const CBlock> &pblock, | bool AcceptBlock(const std::shared_ptr<const CBlock> &pblock, | ||||
BlockValidationState &state, bool fRequested, | BlockValidationState &state, bool fRequested, | ||||
const FlatFilePos *dbp, bool *fNewBlock, | const FlatFilePos *dbp, bool *fNewBlock, | ||||
bool min_pow_checked) EXCLUSIVE_LOCKS_REQUIRED(cs_main); | bool min_pow_checked) EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | public: | ||||
/** Find the last common block of this chain and a locator. */ | /** Find the last common block of this chain and a locator. */ | ||||
const CBlockIndex *FindForkInGlobalIndex(const CBlockLocator &locator) const | const CBlockIndex *FindForkInGlobalIndex(const CBlockLocator &locator) const | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** | /** | ||||
* 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. | * m_options.check_block_index. | ||||
*/ | */ | ||||
void CheckBlockIndex(); | void CheckBlockIndex(); | ||||
/** Load the persisted mempool from disk */ | /** Load the persisted mempool from disk */ | ||||
void | void | ||||
LoadMempool(const fs::path &load_path, | LoadMempool(const fs::path &load_path, | ||||
fsbridge::FopenFn mockable_fopen_function = fsbridge::fopen); | fsbridge::FopenFn mockable_fopen_function = fsbridge::fopen); | ||||
▲ Show 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | public: | ||||
const Config &GetConfig() const { return m_options.config; } | const Config &GetConfig() const { return m_options.config; } | ||||
const CChainParams &GetParams() const { | const CChainParams &GetParams() const { | ||||
return m_options.config.GetChainParams(); | return m_options.config.GetChainParams(); | ||||
} | } | ||||
const Consensus::Params &GetConsensus() const { | const Consensus::Params &GetConsensus() const { | ||||
return m_options.config.GetChainParams().GetConsensus(); | return m_options.config.GetChainParams().GetConsensus(); | ||||
} | } | ||||
bool ShouldCheckBlockIndex() const { | |||||
return *Assert(m_options.check_block_index); | |||||
} | |||||
const arith_uint256 &MinimumChainWork() const { | const arith_uint256 &MinimumChainWork() const { | ||||
return *Assert(m_options.minimum_chain_work); | return *Assert(m_options.minimum_chain_work); | ||||
} | } | ||||
const BlockHash &AssumedValidBlock() const { | const BlockHash &AssumedValidBlock() const { | ||||
return *Assert(m_options.assumed_valid_block); | return *Assert(m_options.assumed_valid_block); | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 253 Lines • Show Last 20 Lines |