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 check code to cross object references round
//! while not having to declare the identical variables and parameters repeatedly, or
//! to make use of globals. Extra variables could possibly be added to this struct (significantly
//! references to validation objects) to remove use of globals
//! and make code extra modular and testable. The struct is not meant to have
//! any member features. It ought to simply be a group of references that may
//! be used with out pulling in undesirable dependencies or performance.
struct NodeContext {
//! libbitcoin_kernel context
std::unique_ptr<kernel::Context> kernel;
//! Init interface for initializing present course of and connecting to different processes.
interfaces::Init* init{nullptr};
std::unique_ptr<AddrMan> addrman;
std::unique_ptr<CConnman> connman;
std::unique_ptr<CTxMemPool> mempool;
std::unique_ptr<const NetGroupManager> netgroupman;
std::unique_ptr<CBlockPolicyEstimator> fee_estimator;
std::unique_ptr<PeerManager> peerman;
std::unique_ptr<ChainstateManager> chainman;
std::unique_ptr<BanMan> banman;
ArgsManager* args{nullptr}; // Presently a uncooked pointer as a result of the reminiscence is just not managed by this struct
std::unique_ptr<interfaces::Chain> chain;
//! Listing of all chain shoppers (pockets processes or different consumer) linked to node.
std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
//! Reference to chain consumer that ought to used to load or create wallets
//! opened by the gui.
interfaces::WalletLoader* wallet_loader{nullptr};
std::unique_ptr<CScheduler> scheduler;
std::operate<void()> rpc_interruption_point = [] {};
//! Declare default constructor and destructor that aren't inline, so code
//! instantiating the NodeContext struct does not must #embody class
//! definitions for all of the unique_ptr members.
NodeContext();
~NodeContext();
};
My assumptions are:
ChainstateManager
managesChainstate
s that arem_ibd_chainstate
andm_snapshot_chainstate
.Chainstate
has all information of a sequence.
Whereas interfaces::Chain
is used for exterior parts similar to pockets, the one potential purpose that involves my thoughts is that the chain
member is for exterior customers of bitcoind
. And by this reality, the implementation of interface::chain
should be solely a easy wrapper over the ChainstateManager
, as a result of I believe all logic is applied there.