Saturday, September 21, 2024
HomeBitcoinc++ - What's the distinction between chain and chainman within the NodeContext...

c++ – What’s the distinction between chain and chainman within the NodeContext within the Bitcoin Core?


Within the NodeContext construction there are two members named chainman and chain. chainman
is occasion of ChainstateManager and chain is occasion of interfaces::Chain. What’s the variations between these two? What’s the variations and why do we’d like each?

//! NodeContext struct containing references to chain state and connection
//! state.
//!
//! That is utilized by init, rpc, and take a look at code to go object references round
//! while not having to declare the identical variables and parameters repeatedly, or
//! to make use of globals. Extra variables might be added to this struct (significantly
//! references to validation objects) to get rid of use of globals
//! and make code extra modular and testable. The struct is not supposed to have
//! any member features. It ought to simply be a set of references that may
//! be used with out pulling in undesirable dependencies or performance.
struct NodeContext {
    //! libbitcoin_kernel context
    std::unique_ptr<:context> kernel;
    //! Init interface for initializing present course of and connecting to different processes.
    interfaces::Init* init{nullptr};
    std::unique_ptr addrman;
    std::unique_ptr connman;
    std::unique_ptr mempool;
    std::unique_ptr netgroupman;
    std::unique_ptr fee_estimator;
    std::unique_ptr peerman;
    std::unique_ptr chainman;
    std::unique_ptr banman;
    ArgsManager* args{nullptr}; // At the moment a uncooked pointer as a result of the reminiscence just isn't managed by this struct
    std::unique_ptr<:chain> chain;
    //! Listing of all chain purchasers (pockets processes or different shopper) related to node.
    std::vector<:unique_ptr>> chain_clients;
    //! Reference to chain shopper that ought to used to load or create wallets
    //! opened by the gui.
    interfaces::WalletLoader* wallet_loader{nullptr};
    std::unique_ptr scheduler;
    std::perform rpc_interruption_point = [] {};

    //! Declare default constructor and destructor that aren't inline, so code
    //! instantiating the NodeContext struct would not must #embrace class
    //! definitions for all of the unique_ptr members.
    NodeContext();
    ~NodeContext();
};

My assumptions are:

  • ChainstateManager manages Chainstates that are m_ibd_chainstate and m_snapshot_chainstate.
  • Chainstate has all knowledge of a sequence.

Whereas interfaces::Chain is used for exterior elements similar to pockets, the one potential cause that involves my thoughts is that the chain member is for exterior customers of bitcoind. And by this truth, the implementation of interface::chain should be solely a easy wrapper over the ChainstateManager, as a result of I believe all logic is carried out there.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments