fuzz coverage

Coverage Report

Created: 2025-06-01 19:34

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