Changeset View
Changeset View
Standalone View
Standalone View
src/validation.h
Show First 20 Lines • Show All 814 Lines • ▼ Show 20 Lines | private: | ||||
BlockManager &m_blockman; | BlockManager &m_blockman; | ||||
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) | ||||
Show All 37 Lines | bool ConnectTip(const Config &config, BlockValidationState &state, | ||||
DisconnectedBlockTransactions &disconnectpool) | DisconnectedBlockTransactions &disconnectpool) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::g_mempool.cs); | EXCLUSIVE_LOCKS_REQUIRED(cs_main, ::g_mempool.cs); | ||||
void InvalidBlockFound(CBlockIndex *pindex, | void InvalidBlockFound(CBlockIndex *pindex, | ||||
const BlockValidationState &state) | const BlockValidationState &state) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
void InvalidChainFound(CBlockIndex *pindexNew) | void InvalidChainFound(CBlockIndex *pindexNew) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
CBlockIndex *FindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main); | CBlockIndex *FindMostWorkChain() EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** | |||||
* The best finalized block. | |||||
* This block cannot be reorged in any way except by explicit user action. | |||||
*/ | |||||
const CBlockIndex *m_finalizedBlockIndex = nullptr; | |||||
deadalnix: Don't define state in random places. Also, this is to be the only blockindex that is in… | |||||
/** Change the currently finalized block index. */ | |||||
void changeFinalizedBlockIndex(const CBlockIndex *); | |||||
deadalnixUnsubmitted Done Inline ActionsI don't see what the function brings, especially since nullptr is a valid state. deadalnix: I don't see what the function brings, especially since nullptr is a valid state. | |||||
bool MarkBlockAsFinal(const Config &config, BlockValidationState &state, | bool MarkBlockAsFinal(const Config &config, BlockValidationState &state, | ||||
const CBlockIndex *pindex) | const CBlockIndex *pindex) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
void ReceivedBlockTransactions(const CBlock &block, CBlockIndex *pindexNew, | void ReceivedBlockTransactions(const CBlock &block, CBlockIndex *pindexNew, | ||||
const FlatFilePos &pos) | const FlatFilePos &pos) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
bool RollforwardBlock(const CBlockIndex *pindex, CCoinsViewCache &inputs, | bool RollforwardBlock(const CBlockIndex *pindex, CCoinsViewCache &inputs, | ||||
const Consensus::Params ¶ms) | const Consensus::Params ¶ms) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
bool UnwindBlock(const Config &config, BlockValidationState &state, | bool UnwindBlock(const Config &config, BlockValidationState &state, | ||||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |
Don't define state in random places. Also, this is to be the only blockindex that is in CChainState. What about others?