LCOV - code coverage report
Current view: top level - src/node - context.h (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 0 1 0.0 %
Date: 2024-01-03 14:57:27 Functions: 0 1 0.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 2019-2022 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 <kernel/context.h>
       9                 :            : 
      10                 :            : #include <atomic>
      11                 :            : #include <cassert>
      12                 :            : #include <cstdlib>
      13                 :            : #include <functional>
      14                 :            : #include <memory>
      15                 :            : #include <vector>
      16                 :            : 
      17                 :            : class ArgsManager;
      18                 :            : class AddrMan;
      19                 :            : class BanMan;
      20                 :            : class BaseIndex;
      21                 :            : class CBlockPolicyEstimator;
      22                 :            : class CConnman;
      23                 :            : class CScheduler;
      24                 :            : class CTxMemPool;
      25                 :            : class ChainstateManager;
      26                 :            : class NetGroupManager;
      27                 :            : class PeerManager;
      28                 :            : namespace interfaces {
      29                 :            : class Chain;
      30                 :            : class ChainClient;
      31                 :            : class Init;
      32                 :            : class WalletLoader;
      33                 :            : } // namespace interfaces
      34                 :            : 
      35                 :            : namespace node {
      36                 :            : class KernelNotifications;
      37                 :            : 
      38                 :            : //! NodeContext struct containing references to chain state and connection
      39                 :            : //! state.
      40                 :            : //!
      41                 :            : //! This is used by init, rpc, and test code to pass object references around
      42                 :            : //! without needing to declare the same variables and parameters repeatedly, or
      43                 :            : //! to use globals. More variables could be added to this struct (particularly
      44                 :            : //! references to validation objects) to eliminate use of globals
      45                 :            : //! and make code more modular and testable. The struct isn't intended to have
      46                 :            : //! any member functions. It should just be a collection of references that can
      47                 :            : //! be used without pulling in unwanted dependencies or functionality.
      48                 :            : struct NodeContext {
      49                 :            :     //! libbitcoin_kernel context
      50                 :            :     std::unique_ptr<kernel::Context> kernel;
      51                 :            :     //! Init interface for initializing current process and connecting to other processes.
      52                 :            :     interfaces::Init* init{nullptr};
      53                 :            :     //! Interrupt object used to track whether node shutdown was requested.
      54                 :            :     util::SignalInterrupt* shutdown{nullptr};
      55                 :            :     std::unique_ptr<AddrMan> addrman;
      56                 :            :     std::unique_ptr<CConnman> connman;
      57                 :            :     std::unique_ptr<CTxMemPool> mempool;
      58                 :            :     std::unique_ptr<const NetGroupManager> netgroupman;
      59                 :            :     std::unique_ptr<CBlockPolicyEstimator> fee_estimator;
      60                 :            :     std::unique_ptr<PeerManager> peerman;
      61                 :            :     std::unique_ptr<ChainstateManager> chainman;
      62                 :            :     std::unique_ptr<BanMan> banman;
      63                 :            :     ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
      64                 :            :     std::vector<BaseIndex*> indexes; // raw pointers because memory is not managed by this struct
      65                 :            :     std::unique_ptr<interfaces::Chain> chain;
      66                 :            :     //! List of all chain clients (wallet processes or other client) connected to node.
      67                 :            :     std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
      68                 :            :     //! Reference to chain client that should used to load or create wallets
      69                 :            :     //! opened by the gui.
      70                 :            :     interfaces::WalletLoader* wallet_loader{nullptr};
      71                 :            :     std::unique_ptr<CScheduler> scheduler;
      72                 :          0 :     std::function<void()> rpc_interruption_point = [] {};
      73                 :            :     std::unique_ptr<KernelNotifications> notifications;
      74                 :            :     std::atomic<int> exit_status{EXIT_SUCCESS};
      75                 :            : 
      76                 :            :     //! Declare default constructor and destructor that are not inline, so code
      77                 :            :     //! instantiating the NodeContext struct doesn't need to #include class
      78                 :            :     //! definitions for all the unique_ptr members.
      79                 :            :     NodeContext();
      80                 :            :     ~NodeContext();
      81                 :            : };
      82                 :            : } // namespace node
      83                 :            : 
      84                 :            : #endif // BITCOIN_NODE_CONTEXT_H

Generated by: LCOV version 1.14