LCOV - code coverage report
Current view: top level - src/node - context.h (source / functions) Hit Total Coverage
Test: test_dash_coverage.info Lines: 1 1 100.0 %
Date: 2026-06-25 07:23:51 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2019-2021 The Bitcoin Core developers
       2             : // Distributed under the MIT software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : 
       5             : #ifndef BITCOIN_NODE_CONTEXT_H
       6             : #define BITCOIN_NODE_CONTEXT_H
       7             : 
       8             : #include <cassert>
       9             : #include <functional>
      10             : #include <memory>
      11             : #include <vector>
      12             : 
      13             : class ArgsManager;
      14             : class BanMan;
      15             : class CActiveMasternodeManager;
      16             : class AddrMan;
      17             : class CBlockPolicyEstimator;
      18             : class CConnman;
      19             : class CDeterministicMNManager;
      20             : class CDSTXManager;
      21             : class CChainstateHelper;
      22             : class ChainstateManager;
      23             : class CEvoDB;
      24             : class CGovernanceManager;
      25             : class CJWalletManager;
      26             : class CMasternodeMetaMan;
      27             : class CMasternodeSync;
      28             : class CNetFulfilledRequestManager;
      29             : class CScheduler;
      30             : class CSporkManager;
      31             : class CTxMemPool;
      32             : class NetGroupManager;
      33             : class PeerManager;
      34             : struct ActiveContext;
      35             : struct LLMQContext;
      36             : 
      37             : namespace chainlock {
      38             : class Chainlocks;
      39             : class ChainlockHandler;
      40             : } // namespace chainlock
      41             : 
      42             : namespace interfaces {
      43             : class Chain;
      44             : class ChainClient;
      45             : class Init;
      46             : class WalletLoader;
      47             : namespace CoinJoin {
      48             : class Loader;
      49             : } // namspace CoinJoin
      50             : } // namespace interfaces
      51             : 
      52             : namespace llmq {
      53             : struct ObserverContext;
      54             : } // namespace llmq
      55             : 
      56             : namespace node {
      57             : //! NodeContext struct containing references to chain state and connection
      58             : //! state.
      59             : //!
      60             : //! This is used by init, rpc, and test code to pass object references around
      61             : //! without needing to declare the same variables and parameters repeatedly, or
      62             : //! to use globals. More variables could be added to this struct (particularly
      63             : //! references to validation objects) to eliminate use of globals
      64             : //! and make code more modular and testable. The struct isn't intended to have
      65             : //! any member functions. It should just be a collection of references that can
      66             : //! be used without pulling in unwanted dependencies or functionality.
      67             : struct NodeContext {
      68             :     //! Init interface for initializing current process and connecting to other processes.
      69             :     interfaces::Init* init{nullptr};
      70             :     std::unique_ptr<AddrMan> addrman;
      71             :     std::unique_ptr<CConnman> connman;
      72             :     std::unique_ptr<CTxMemPool> mempool;
      73             :     std::unique_ptr<const NetGroupManager> netgroupman;
      74             :     std::unique_ptr<CBlockPolicyEstimator> fee_estimator;
      75             :     std::unique_ptr<PeerManager> peerman;
      76             :     std::unique_ptr<ChainstateManager> chainman;
      77             :     std::unique_ptr<BanMan> banman;
      78             :     ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
      79             :     std::unique_ptr<interfaces::Chain> chain;
      80             :     //! List of all chain clients (wallet processes or other client) connected to node.
      81             :     std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
      82             :     //! Reference to chain client that should used to load or create wallets
      83             :     //! opened by the gui.
      84             :     interfaces::WalletLoader* wallet_loader{nullptr};
      85             :     std::unique_ptr<interfaces::CoinJoin::Loader> coinjoin_loader{nullptr};
      86             :     std::unique_ptr<CScheduler> scheduler;
      87        1089 :     std::function<void()> rpc_interruption_point = [] {};
      88             :     //! Dash managers
      89             :     std::unique_ptr<CJWalletManager> cj_walletman;
      90             :     std::unique_ptr<CDSTXManager> dstxman;
      91             :     std::unique_ptr<CEvoDB> evodb;
      92             :     std::unique_ptr<CChainstateHelper> chain_helper;
      93             :     std::unique_ptr<CDeterministicMNManager> dmnman;
      94             :     std::unique_ptr<CGovernanceManager> govman;
      95             :     std::unique_ptr<CMasternodeMetaMan> mn_metaman;
      96             :     std::unique_ptr<CMasternodeSync> mn_sync;
      97             :     std::unique_ptr<CNetFulfilledRequestManager> netfulfilledman;
      98             :     std::unique_ptr<CSporkManager> sporkman;
      99             :     std::unique_ptr<chainlock::Chainlocks> chainlocks;
     100             :     std::unique_ptr<chainlock::ChainlockHandler> clhandler;
     101             :     //! Dash contexts
     102             :     std::unique_ptr<ActiveContext> active_ctx;
     103             :     std::unique_ptr<LLMQContext> llmq_ctx;
     104             :     std::unique_ptr<llmq::ObserverContext> observer_ctx;
     105             : 
     106             :     //! Declare default constructor and destructor that are not inline, so code
     107             :     //! instantiating the NodeContext struct doesn't need to #include class
     108             :     //! definitions for all the unique_ptr members.
     109             :     NodeContext();
     110             :     ~NodeContext();
     111             : };
     112             : } // namespace node
     113             : 
     114             : #endif // BITCOIN_NODE_CONTEXT_H

Generated by: LCOV version 1.16