Bitcoin Core Fuzz Coverage Report for #26966

Coverage Report

Created: 2025-10-10 09:12

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