Bitcoin ABC  0.24.7
P2P Digital Currency
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
CChainState Class Reference

CChainState stores and provides an API to update our local knowledge of the current best chain. More...

#include <validation.h>

Collaboration diagram for CChainState:
[legend]

Public Member Functions

 CChainState (CTxMemPool &mempool, BlockManager &blockman, BlockHash from_snapshot_blockhash=BlockHash())
 
void InitCoinsDB (size_t cache_size_bytes, bool in_memory, bool should_wipe, std::string leveldb_name="chainstate")
 Initialize the CoinsViews UTXO set database management data structures. More...
 
CCoinsViewCacheCoinsTip () EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
CCoinsViewDBCoinsDB ()
 
CCoinsViewErrorCatcherCoinsErrorCatcher () EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
void ResetCoinsViews ()
 Destructs all objects related to accessing the UTXO set. More...
 
void ForceFlushStateToDisk ()
 Unconditionally flush all changes to disk. More...
 
void PruneAndFlush ()
 Prune blockfiles from the disk if necessary and then flush chainstate changes if we pruned. More...
 
bool ActivateBestChain (const Config &config, BlockValidationState &state, std::shared_ptr< const CBlock > pblock=std::shared_ptr< const CBlock >()) LOCKS_EXCLUDED(cs_main)
 Make the best chain active, in multiple steps. More...
 
bool AcceptBlock (const Config &config, const std::shared_ptr< const CBlock > &pblock, BlockValidationState &state, bool fRequested, const FlatFilePos *dbp, bool *fNewBlock) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Store a block on disk. More...
 
DisconnectResult DisconnectBlock (const CBlock &block, const CBlockIndex *pindex, CCoinsViewCache &view)
 Undo the effects of this block (with given index) on the UTXO set represented by coins. More...
 
bool ConnectBlock (const CBlock &block, BlockValidationState &state, CBlockIndex *pindex, CCoinsViewCache &view, const CChainParams &params, BlockValidationOptions options, bool fJustCheck=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Apply the effects of this block (with given index) on the UTXO set represented by coins. More...
 
bool DisconnectTip (const CChainParams &params, BlockValidationState &state, DisconnectedBlockTransactions *disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main
 Disconnect m_chain's tip. More...
 
bool PreciousBlock (const Config &config, BlockValidationState &state, CBlockIndex *pindex) LOCKS_EXCLUDED(cs_main)
 
bool InvalidateBlock (const Config &config, BlockValidationState &state, CBlockIndex *pindex) LOCKS_EXCLUDED(cs_main) EXCLUSIVE_LOCKS_REQUIRED(!m_cs_chainstate)
 Mark a block as invalid. More...
 
bool ParkBlock (const Config &config, BlockValidationState &state, CBlockIndex *pindex) LOCKS_EXCLUDED(cs_main) EXCLUSIVE_LOCKS_REQUIRED(!m_cs_chainstate)
 Park a block. More...
 
bool FinalizeBlock (const Config &config, BlockValidationState &state, CBlockIndex *pindex) LOCKS_EXCLUDED(cs_main) EXCLUSIVE_LOCKS_REQUIRED(!m_cs_chainstate)
 Finalize a block. More...
 
const CBlockIndexGetFinalizedBlock () const EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Return the currently finalized block index. More...
 
bool IsBlockFinalized (const CBlockIndex *pindex) const EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Checks if a block is finalized. More...
 
void ResetBlockFailureFlags (CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
template<typename F >
bool UpdateFlagsForBlock (CBlockIndex *pindexBase, CBlockIndex *pindex, F f) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
template<typename F , typename C , typename AC >
void UpdateFlags (CBlockIndex *pindex, CBlockIndex *&pindexReset, F f, C fChild, AC fAncestorWasChanged) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
void UnparkBlockImpl (CBlockIndex *pindex, bool fClearChildren) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Remove parked status from a block and its descendants. More...
 
bool ReplayBlocks (const Consensus::Params &params)
 Replay blocks that aren't fully applied to the database. More...
 
bool LoadGenesisBlock (const CChainParams &chainparams)
 
void PruneBlockIndexCandidates ()
 Delete all entries in setBlockIndexCandidates that are worse than the current tip. More...
 
void UnloadBlockIndex () EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
bool IsInitialBlockDownload () const
 Check whether we are doing an initial block download (synchronizing from disk or network) More...
 
void CheckBlockIndex (const Consensus::Params &consensusParams)
 Make various assertions about the state of the block index. More...
 
void LoadMempool (const Config &config, const ArgsManager &args)
 Load the persisted mempool from disk. More...
 
bool LoadChainTip (const CChainParams &chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Update the chain tip based on database information, i.e. More...
 

Public Attributes

CChain m_chain
 The current chain of blockheaders we consult and build on. More...
 
const BlockHash m_from_snapshot_blockhash {}
 The blockhash which is the base of the snapshot this chainstate was created from. More...
 
std::set< CBlockIndex *, CBlockIndexWorkComparatorsetBlockIndexCandidates
 The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS (for itself and all ancestors) and as good as our current tip or better. More...
 
size_t m_coinsdb_cache_size_bytes {0}
 The cache size of the on-disk coins view. More...
 
size_t m_coinstip_cache_size_bytes {0}
 The cache size of the in-memory coins view. More...
 
bool m_mempool cs
 

Private Member Functions

const CBlockIndex *m_finalizedBlockIndex GUARDED_BY (cs_main)
 The best finalized block. More...
 
bool ActivateBestChainStep (const Config &config, BlockValidationState &state, CBlockIndex *pindexMostWork, const std::shared_ptr< const CBlock > &pblock, bool &fInvalidFound, ConnectTrace &connectTrace) EXCLUSIVE_LOCKS_REQUIRED(cs_main
 Dictates whether we need to flush the cache to disk or not. More...
 
bool ConnectTip (const Config &config, BlockValidationState &state, CBlockIndex *pindexNew, const std::shared_ptr< const CBlock > &pblock, ConnectTrace &connectTrace, DisconnectedBlockTransactions &disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main
 Connect a new block to m_chain. More...
 
void InvalidBlockFound (CBlockIndex *pindex, const BlockValidationState &state) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
void InvalidChainFound (CBlockIndex *pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
CBlockIndexFindMostWorkChain () EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Return the tip of the chain with the most work in it, that isn't known to be invalid (it's however far from certain to be valid). More...
 
bool MarkBlockAsFinal (BlockValidationState &state, const CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
void ReceivedBlockTransactions (const CBlock &block, CBlockIndex *pindexNew, const FlatFilePos &pos) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS). More...
 
bool RollforwardBlock (const CBlockIndex *pindex, CCoinsViewCache &inputs, const Consensus::Params &params) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Apply the effects of a block on the utxo cache, ignoring that it may already have been applied. More...
 
bool UnwindBlock (const Config &config, BlockValidationState &state, CBlockIndex *pindex, bool invalidate) EXCLUSIVE_LOCKS_REQUIRED(m_cs_chainstate)
 

Private Attributes

RecursiveMutex m_cs_chainstate
 the ChainState CriticalSection A lock that must be held when modifying this ChainState - held in ActivateBestChain() More...
 
std::atomic< int32_t > nBlockSequenceId {1}
 Every received block is assigned a unique and increasing identifier, so we know which one to give priority in case of a fork. More...
 
int32_t nBlockReverseSequenceId = -1
 Decreasing counter (used by subsequent preciousblock calls). More...
 
arith_uint256 nLastPreciousChainwork = 0
 chainwork for the last block that preciousblock has been applied to. More...
 
std::atomic< bool > m_cached_finished_ibd {false}
 Whether this chainstate is undergoing initial block download. More...
 
BlockManagerm_blockman
 Reference to a BlockManager instance which itself is shared across all CChainState instances. More...
 
CTxMemPoolm_mempool
 mempool that is kept in sync with the chain More...
 
std::unique_ptr< CoinsViewsm_coins_views
 Manages the UTXO set, which is a reflection of the contents of m_chain. More...
 
friend ChainstateManager
 

Detailed Description

CChainState stores and provides an API to update our local knowledge of the current best chain.

Eventually, the API here is targeted at being exposed externally as a consumable libconsensus library, so any functions added must only call other class member functions, pure functions in other parts of the consensus library, callbacks via the validation interface, or read/write-to-disk functions (eventually this will also be via callbacks).

Anything that is contingent on the current tip of the chain is stored here, whereas block information and metadata independent of the current tip is kept in BlockMetadataManager.

Definition at line 745 of file validation.h.

Constructor & Destructor Documentation

◆ CChainState()

CChainState::CChainState ( CTxMemPool mempool,
BlockManager blockman,
BlockHash  from_snapshot_blockhash = BlockHash() 
)
explicit

Definition at line 872 of file validation.cpp.

Member Function Documentation

◆ AcceptBlock()

bool CChainState::AcceptBlock ( const Config config,
const std::shared_ptr< const CBlock > &  pblock,
BlockValidationState state,
bool  fRequested,
const FlatFilePos dbp,
bool *  fNewBlock 
)

Store a block on disk.

Parameters
[in]configThe global config.
[in-out]pblock The block we want to accept.
[in]fRequestedA boolean to indicate if this block was requested from our peers.
[in]dbpIf non-null, the disk position of the block.
[in-out]fNewBlock True if block was first received via this call.
Returns
True if the block is accepted as a valid block and written to disk.

Definition at line 4241 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ActivateBestChain()

bool CChainState::ActivateBestChain ( const Config config,
BlockValidationState state,
std::shared_ptr< const CBlock pblock = std::shared_ptr<const CBlock>() 
)

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 to a block that is already loaded (to avoid loading it again from disk).

ActivateBestChain is split into steps (see ActivateBestChainStep) so that 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.

May not be called with cs_main held. May not be called in a validationinterface callback.

Returns
true unless a system error occurred

Definition at line 2988 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ActivateBestChainStep()

bool CChainState::ActivateBestChainStep ( const Config config,
BlockValidationState state,
CBlockIndex pindexMostWork,
const std::shared_ptr< const CBlock > &  pblock,
bool &  fInvalidFound,
ConnectTrace connectTrace 
)
private

Dictates whether we need to flush the cache to disk or not.

Try to make some progress towards making pindexMostWork the active block.

Returns
the state of the size of the coins cache.

pblock is either nullptr or a pointer to a CBlock corresponding to pindexMostWork.

Returns
true unless a system error occurred

Definition at line 2838 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckBlockIndex()

void CChainState::CheckBlockIndex ( const Consensus::Params consensusParams)

Make various assertions about the state of the block index.

By default this only executes fully when using the Regtest chain; see: fCheckBlockIndex.

Definition at line 5405 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CoinsDB()

CCoinsViewDB& CChainState::CoinsDB ( )
inline
Returns
A reference to the on-disk UTXO set database.

Definition at line 843 of file validation.h.

Here is the caller graph for this function:

◆ CoinsErrorCatcher()

CCoinsViewErrorCatcher& CChainState::CoinsErrorCatcher ( )
inline
Returns
A reference to a wrapped view of the in-memory UTXO set that handles disk read errors gracefully.

Definition at line 847 of file validation.h.

◆ CoinsTip()

CCoinsViewCache& CChainState::CoinsTip ( )
inline
Returns
A reference to the in-memory cache of the UTXO set.

Definition at line 837 of file validation.h.

Here is the caller graph for this function:

◆ ConnectBlock()

bool CChainState::ConnectBlock ( const CBlock block,
BlockValidationState state,
CBlockIndex pindex,
CCoinsViewCache view,
const CChainParams params,
BlockValidationOptions  options,
bool  fJustCheck = false 
)

Apply the effects of this block (with given index) on the UTXO set represented by coins.

Validity checks that depend on the UTXO set are also done; ConnectBlock() can fail if those validity checks fail (among other reasons).

Definition at line 1612 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConnectTip()

bool CChainState::ConnectTip ( const Config config,
BlockValidationState state,
CBlockIndex pindexNew,
const std::shared_ptr< const CBlock > &  pblock,
ConnectTrace connectTrace,
DisconnectedBlockTransactions disconnectpool 
)
private

Connect a new block to m_chain.

pblock is either nullptr or a pointer to a CBlock corresponding to pindexNew, to bypass loading it again from disk.

The block is always added to connectTrace (either after loading from disk or by copying pblock) - if that is not intended, care must be taken to remove the last entry in blocksConnected in case of failure.

Definition at line 2527 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DisconnectBlock()

DisconnectResult CChainState::DisconnectBlock ( const CBlock block,
const CBlockIndex pindex,
CCoinsViewCache view 
)

Undo the effects of this block (with given index) on the UTXO set represented by coins.

When FAILED is returned, view is left in an indeterminate state.

Definition at line 1362 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DisconnectTip()

bool CChainState::DisconnectTip ( const CChainParams params,
BlockValidationState state,
DisconnectedBlockTransactions disconnectpool 
)

Disconnect m_chain's tip.

After calling, the mempool will be in an inconsistent state, with transactions from disconnected blocks being added to disconnectpool. You should make the mempool consistent again by calling updateMempoolForReorg. with cs_main held.

If disconnectpool is nullptr, then no disconnected transactions are added to disconnectpool (note that the caller is responsible for mempool consistency in any case).

Definition at line 2320 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FinalizeBlock()

bool CChainState::FinalizeBlock ( const Config config,
BlockValidationState state,
CBlockIndex pindex 
)

Finalize a block.

A finalized block can not be reorged in any way.

Definition at line 3379 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindMostWorkChain()

CBlockIndex * CChainState::FindMostWorkChain ( )
private

Return the tip of the chain with the most work in it, that isn't known to be invalid (it's however far from certain to be valid).

Definition at line 2651 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ForceFlushStateToDisk()

void CChainState::ForceFlushStateToDisk ( )

Unconditionally flush all changes to disk.

Definition at line 2264 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFinalizedBlock()

const CBlockIndex * CChainState::GetFinalizedBlock ( ) const

Return the currently finalized block index.

Definition at line 3537 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GUARDED_BY()

const CBlockIndex* m_finalizedBlockIndex CChainState::GUARDED_BY ( cs_main  )
private

The best finalized block.

This block cannot be reorged in any way except by explicit user action.

◆ InitCoinsDB()

void CChainState::InitCoinsDB ( size_t  cache_size_bytes,
bool  in_memory,
bool  should_wipe,
std::string  leveldb_name = "chainstate" 
)

Initialize the CoinsViews UTXO set database management data structures.

The in-memory cache is initialized separately.

All parameters forwarded to CoinsViews.

Definition at line 877 of file validation.cpp.

Here is the call graph for this function:

◆ InvalidateBlock()

bool CChainState::InvalidateBlock ( const Config config,
BlockValidationState state,
CBlockIndex pindex 
)

Mark a block as invalid.

Definition at line 3360 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InvalidBlockFound()

void CChainState::InvalidBlockFound ( CBlockIndex pindex,
const BlockValidationState state 
)
private

Definition at line 1061 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InvalidChainFound()

void CChainState::InvalidChainFound ( CBlockIndex pindexNew)
private

Definition at line 1028 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsBlockFinalized()

bool CChainState::IsBlockFinalized ( const CBlockIndex pindex) const

Checks if a block is finalized.

Definition at line 3530 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsInitialBlockDownload()

bool CChainState::IsInitialBlockDownload ( ) const

Check whether we are doing an initial block download (synchronizing from disk or network)

Definition at line 897 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadChainTip()

bool CChainState::LoadChainTip ( const CChainParams chainparams)

Update the chain tip based on database information, i.e.

CoinsTip()'s best block.

Definition at line 4826 of file validation.cpp.

Here is the call graph for this function:

◆ LoadGenesisBlock()

bool CChainState::LoadGenesisBlock ( const CChainParams chainparams)

Definition at line 5214 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadMempool()

void CChainState::LoadMempool ( const Config config,
const ArgsManager args 
)

Load the persisted mempool from disk.

Definition at line 4819 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MarkBlockAsFinal()

bool CChainState::MarkBlockAsFinal ( BlockValidationState state,
const CBlockIndex pindex 
)
private

Definition at line 2441 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParkBlock()

bool CChainState::ParkBlock ( const Config config,
BlockValidationState state,
CBlockIndex pindex 
)

Park a block.

Definition at line 3370 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PreciousBlock()

bool CChainState::PreciousBlock ( const Config config,
BlockValidationState state,
CBlockIndex pindex 
)

Definition at line 3131 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PruneAndFlush()

void CChainState::PruneAndFlush ( )

Prune blockfiles from the disk if necessary and then flush chainstate changes if we pruned.

Definition at line 2273 of file validation.cpp.

Here is the call graph for this function:

◆ PruneBlockIndexCandidates()

void CChainState::PruneBlockIndexCandidates ( )

Delete all entries in setBlockIndexCandidates that are worse than the current tip.

Definition at line 2817 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReceivedBlockTransactions()

void CChainState::ReceivedBlockTransactions ( const CBlock block,
CBlockIndex pindexNew,
const FlatFilePos pos 
)
private

Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS).

Definition at line 3589 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReplayBlocks()

bool CChainState::ReplayBlocks ( const Consensus::Params params)

Replay blocks that aren't fully applied to the database.

Definition at line 5059 of file validation.cpp.

Here is the call graph for this function:

◆ ResetBlockFailureFlags()

void CChainState::ResetBlockFailureFlags ( CBlockIndex pindex)

Definition at line 3478 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetCoinsViews()

void CChainState::ResetCoinsViews ( )
inline

Destructs all objects related to accessing the UTXO set.

Definition at line 853 of file validation.h.

◆ RollforwardBlock()

bool CChainState::RollforwardBlock ( const CBlockIndex pindex,
CCoinsViewCache inputs,
const Consensus::Params params 
)
private

Apply the effects of a block on the utxo cache, ignoring that it may already have been applied.

Definition at line 5031 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnloadBlockIndex()

void CChainState::UnloadBlockIndex ( )

Definition at line 5159 of file validation.cpp.

◆ UnparkBlockImpl()

void CChainState::UnparkBlockImpl ( CBlockIndex pindex,
bool  fClearChildren 
)

Remove parked status from a block and its descendants.

Definition at line 3505 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnwindBlock()

bool CChainState::UnwindBlock ( const Config config,
BlockValidationState state,
CBlockIndex pindex,
bool  invalidate 
)
private

Definition at line 3175 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateFlags()

template<typename F , typename C , typename AC >
void CChainState::UpdateFlags ( CBlockIndex pindex,
CBlockIndex *&  pindexReset,
f,
fChild,
AC  fAncestorWasChanged 
)

Definition at line 3447 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateFlagsForBlock()

template<typename F >
bool CChainState::UpdateFlagsForBlock ( CBlockIndex pindexBase,
CBlockIndex pindex,
f 
)

Definition at line 3423 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ ChainstateManager

friend CChainState::ChainstateManager
private

Definition at line 1044 of file validation.h.

◆ cs

bool m_mempool CChainState::cs

Definition at line 926 of file validation.h.

◆ m_blockman

BlockManager& CChainState::m_blockman
private

Reference to a BlockManager instance which itself is shared across all CChainState instances.

Keeping a local reference allows us to test more easily as opposed to referencing a global.

Definition at line 776 of file validation.h.

◆ m_cached_finished_ibd

std::atomic<bool> CChainState::m_cached_finished_ibd {false}
mutableprivate

Whether this chainstate is undergoing initial block download.

Mutable because we need to be able to mark IsInitialBlockDownload() const, which latches this for caching purposes.

Definition at line 771 of file validation.h.

◆ m_chain

CChain CChainState::m_chain

The current chain of blockheaders we consult and build on.

See also
CChain, CBlockIndex.

Definition at line 818 of file validation.h.

◆ m_coins_views

std::unique_ptr<CoinsViews> CChainState::m_coins_views
private

Manages the UTXO set, which is a reflection of the contents of m_chain.

Definition at line 783 of file validation.h.

◆ m_coinsdb_cache_size_bytes

size_t CChainState::m_coinsdb_cache_size_bytes {0}

The cache size of the on-disk coins view.

Definition at line 856 of file validation.h.

◆ m_coinstip_cache_size_bytes

size_t CChainState::m_coinstip_cache_size_bytes {0}

The cache size of the in-memory coins view.

Definition at line 859 of file validation.h.

◆ m_cs_chainstate

RecursiveMutex CChainState::m_cs_chainstate
private

the ChainState CriticalSection A lock that must be held when modifying this ChainState - held in ActivateBestChain()

Definition at line 752 of file validation.h.

◆ m_from_snapshot_blockhash

const BlockHash CChainState::m_from_snapshot_blockhash {}

The blockhash which is the base of the snapshot this chainstate was created from.

IsNull() if this chainstate was not created from a snapshot.

Definition at line 826 of file validation.h.

◆ m_mempool

CTxMemPool& CChainState::m_mempool
private

mempool that is kept in sync with the chain

Definition at line 779 of file validation.h.

◆ nBlockReverseSequenceId

int32_t CChainState::nBlockReverseSequenceId = -1
private

Decreasing counter (used by subsequent preciousblock calls).

Definition at line 761 of file validation.h.

◆ nBlockSequenceId

std::atomic<int32_t> CChainState::nBlockSequenceId {1}
private

Every received block is assigned a unique and increasing identifier, so we know which one to give priority in case of a fork.

Blocks loaded from disk are assigned id 0, so start the counter at 1.

Definition at line 759 of file validation.h.

◆ nLastPreciousChainwork

arith_uint256 CChainState::nLastPreciousChainwork = 0
private

chainwork for the last block that preciousblock has been applied to.

Definition at line 763 of file validation.h.

◆ setBlockIndexCandidates

std::set<CBlockIndex *, CBlockIndexWorkComparator> CChainState::setBlockIndexCandidates

The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS (for 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 for the block.

Definition at line 834 of file validation.h.


The documentation for this class was generated from the following files: