What do the classes ChainstateManager
, CChainState
, CChain
and BlockManager
do?
A graphic from Doxygen showing how the classes interact:

ChainstateManager
: Provides an interface for creating and interacting with one or two chainstates
CChainState
: Stores and provides an API to update our local knowledge of the current best chain.
CChain
: An in-memory indexed chain of blocks. It was introduced in PR 3077.
BlockManager
: Maintains a tree of blocks (stored in m_block_index
) which is consulted to determine where the most-work tip is.
Why do CChainState
and CChain
have a leading 'C', but ChainstateManager
and BlockManager
don't?
C stands for class using Hungarian style naming.
The current style in Bitcoin Core is not to use Hungarian notation. Bitcoin Core uses m_
to represent member variables, g_
to represent globals, and no prefix to represent local variables/parameters. CChainState
and CChain
were named prior to these style guidelines being implemented in Bitcoin Core.
These were answered by John Newbery and other participants of the May 12th 2021 Bitcoin Core PR review club.