Changeset View
Changeset View
Standalone View
Standalone View
src/validation.h
Show First 20 Lines • Show All 808 Lines • ▼ Show 20 Lines | private: | ||||
*/ | */ | ||||
mutable std::atomic<bool> m_cached_finished_ibd{false}; | mutable std::atomic<bool> m_cached_finished_ibd{false}; | ||||
//! Reference to a BlockManager instance which itself is shared across all | //! Reference to a BlockManager instance which itself is shared across all | ||||
//! CChainState instances. Keeping a local reference allows us to test more | //! CChainState instances. Keeping a local reference allows us to test more | ||||
//! easily as opposed to referencing a global. | //! easily as opposed to referencing a global. | ||||
BlockManager &m_blockman; | BlockManager &m_blockman; | ||||
/** | |||||
* The best finalized block. | |||||
* This block cannot be reorged in any way except by explicit user action. | |||||
*/ | |||||
const CBlockIndex *m_finalizedBlockIndex GUARDED_BY(cs_main) = nullptr; | |||||
public: | public: | ||||
explicit CChainState(BlockManager &blockman) : m_blockman(blockman) {} | explicit CChainState(BlockManager &blockman) : m_blockman(blockman) {} | ||||
//! The current chain of blockheaders we consult and build on. | //! The current chain of blockheaders we consult and build on. | ||||
//! @see CChain, CBlockIndex. | //! @see CChain, CBlockIndex. | ||||
CChain m_chain; | CChain m_chain; | ||||
CBlockIndex const *pindexFinalized = nullptr; | |||||
/** | /** | ||||
* The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS (for | * The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS (for | ||||
* itself and all ancestors) and as good as our current tip or better. | * itself and all ancestors) and as good as our current tip or better. | ||||
* Entries may be failed, though, and pruning nodes may be missing the data | * Entries may be failed, though, and pruning nodes may be missing the data | ||||
* for the block. | * for the block. | ||||
*/ | */ | ||||
std::set<CBlockIndex *, CBlockIndexWorkComparator> setBlockIndexCandidates; | std::set<CBlockIndex *, CBlockIndexWorkComparator> setBlockIndexCandidates; | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | public: | ||||
/** Mark a block as invalid. */ | /** Mark a block as invalid. */ | ||||
bool InvalidateBlock(const Config &config, BlockValidationState &state, | bool InvalidateBlock(const Config &config, BlockValidationState &state, | ||||
CBlockIndex *pindex) | CBlockIndex *pindex) | ||||
LOCKS_EXCLUDED(cs_main, m_cs_chainstate); | LOCKS_EXCLUDED(cs_main, m_cs_chainstate); | ||||
/** Park a block. */ | /** Park a block. */ | ||||
bool ParkBlock(const Config &config, BlockValidationState &state, | bool ParkBlock(const Config &config, BlockValidationState &state, | ||||
CBlockIndex *pindex) | CBlockIndex *pindex) | ||||
LOCKS_EXCLUDED(cs_main, m_cs_chainstate); | LOCKS_EXCLUDED(cs_main, m_cs_chainstate); | ||||
/** | /** | ||||
* Finalize a block. | * Finalize a block. | ||||
* A finalized block can not be reorged in any way. | * A finalized block can not be reorged in any way. | ||||
*/ | */ | ||||
bool FinalizeBlock(const Config &config, BlockValidationState &state, | bool FinalizeBlock(const Config &config, BlockValidationState &state, | ||||
CBlockIndex *pindex) | CBlockIndex *pindex) | ||||
LOCKS_EXCLUDED(cs_main, m_cs_chainstate); | LOCKS_EXCLUDED(cs_main, m_cs_chainstate); | ||||
/** Return the currently finalized block index. */ | |||||
const CBlockIndex *finalizedBlockIndex() const; | |||||
void ResetBlockFailureFlags(CBlockIndex *pindex) | void ResetBlockFailureFlags(CBlockIndex *pindex) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
template <typename F> | template <typename F> | ||||
bool UpdateFlagsForBlock(CBlockIndex *pindexBase, CBlockIndex *pindex, F f) | bool UpdateFlagsForBlock(CBlockIndex *pindexBase, CBlockIndex *pindex, F f) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
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); | bool ReplayBlocks(const Consensus::Params ¶ms, CCoinsView *view); | ||||
bool LoadGenesisBlock(const CChainParams &chainparams); | bool LoadGenesisBlock(const CChainParams &chainparams); | ||||
void PruneBlockIndexCandidates(); | void PruneBlockIndexCandidates(); | ||||
void UnloadBlockIndex(); | 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; | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 133 Lines • Show Last 20 Lines |