Skip to content

Commit 90fc8b0

Browse files
committed
Add src/node/* code to node:: namespace
1 parent 4ada742 commit 90fc8b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+283
-61
lines changed

src/bench/coin_selection.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#include <set>
1313

14+
using node::NodeContext;
15+
1416
static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector<std::unique_ptr<CWalletTx>>& wtxs)
1517
{
1618
static int nextLockTime = 0;

src/bitcoind.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <functional>
3131
#include <optional>
3232

33+
using node::NodeContext;
34+
3335
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
3436
UrlDecodeFn* const URL_DECODE = urlDecode;
3537

src/dummywallet.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class DummyWalletInit : public WalletInitInterface {
2121
bool HasWalletSupport() const override {return false;}
2222
void AddWalletOptions(ArgsManager& argsman) const override;
2323
bool ParameterInteraction() const override {return true;}
24-
void Construct(NodeContext& node) const override {LogPrintf("No wallet support compiled in!\n");}
24+
void Construct(node::NodeContext& node) const override {LogPrintf("No wallet support compiled in!\n");}
2525
};
2626

2727
void DummyWalletInit::AddWalletOptions(ArgsManager& argsman) const

src/index/base.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <validation.h> // For g_chainman
1515
#include <warnings.h>
1616

17+
using node::ReadBlockFromDisk;
18+
1719
constexpr uint8_t DB_BEST_BLOCK{'B'};
1820

1921
constexpr int64_t SYNC_LOG_INTERVAL = 30; // seconds

src/index/blockfilterindex.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <node/blockstorage.h>
1010
#include <util/system.h>
1111

12+
using node::UndoReadFromDisk;
13+
1214
/* The index database stores three items for each block: the disk location of the encoded filter,
1315
* its dSHA256 hash, and the header. Those belonging to blocks on the active chain are indexed by
1416
* height, and those belonging to blocks that have been reorganized out of the active chain are

src/index/coinstatsindex.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
#include <undo.h>
1313
#include <validation.h>
1414

15+
using node::CCoinsStats;
16+
using node::GetBogoSize;
17+
using node::ReadBlockFromDisk;
18+
using node::TxOutSer;
19+
using node::UndoReadFromDisk;
20+
1521
static constexpr uint8_t DB_BLOCK_HASH{'s'};
1622
static constexpr uint8_t DB_BLOCK_HEIGHT{'t'};
1723
static constexpr uint8_t DB_MUHASH{'M'};

src/index/coinstatsindex.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class CoinStatsIndex final : public BaseIndex
5252
explicit CoinStatsIndex(size_t n_cache_size, bool f_memory = false, bool f_wipe = false);
5353

5454
// Look up stats for a specific block using CBlockIndex
55-
bool LookUpStats(const CBlockIndex* block_index, CCoinsStats& coins_stats) const;
55+
bool LookUpStats(const CBlockIndex* block_index, node::CCoinsStats& coins_stats) const;
5656
};
5757

5858
/// The global UTXO set hash object.

src/index/txindex.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <util/system.h>
1010
#include <validation.h>
1111

12+
using node::OpenBlockFile;
13+
1214
constexpr uint8_t DB_TXINDEX{'t'};
1315

1416
std::unique_ptr<TxIndex> g_txindex;

src/init.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,22 @@
9595
#include <zmq/zmqrpc.h>
9696
#endif
9797

98+
using node::CacheSizes;
99+
using node::CalculateCacheSizes;
100+
using node::ChainstateLoadVerifyError;
101+
using node::ChainstateLoadingError;
102+
using node::CleanupBlockRevFiles;
103+
using node::DEFAULT_PRINTPRIORITY;
104+
using node::DEFAULT_STOPAFTERBLOCKIMPORT;
105+
using node::LoadChainstate;
106+
using node::NodeContext;
107+
using node::ThreadImport;
108+
using node::VerifyLoadedChainstate;
109+
using node::fHavePruned;
110+
using node::fPruneMode;
111+
using node::fReindex;
112+
using node::nPruneTarget;
113+
98114
static const bool DEFAULT_PROXYRANDOMIZE = true;
99115
static const bool DEFAULT_REST_ENABLE = false;
100116

src/init.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ static constexpr bool DEFAULT_DAEMON = false;
1616
static constexpr bool DEFAULT_DAEMONWAIT = false;
1717

1818
class ArgsManager;
19-
struct NodeContext;
2019
namespace interfaces {
2120
struct BlockAndHeaderTipInfo;
2221
}
22+
namespace node {
23+
struct NodeContext;
24+
} // namespace node
2325

2426
/** Interrupt threads */
25-
void Interrupt(NodeContext& node);
26-
void Shutdown(NodeContext& node);
27+
void Interrupt(node::NodeContext& node);
28+
void Shutdown(node::NodeContext& node);
2729
//!Initialize the logging infrastructure
2830
void InitLogging(const ArgsManager& args);
2931
//!Parameter interaction: change current parameters depending on various rules
@@ -55,13 +57,13 @@ bool AppInitLockDataDirectory();
5557
/**
5658
* Initialize node and wallet interface pointers. Has no prerequisites or side effects besides allocating memory.
5759
*/
58-
bool AppInitInterfaces(NodeContext& node);
60+
bool AppInitInterfaces(node::NodeContext& node);
5961
/**
6062
* Bitcoin core main initialization.
6163
* @note This should only be done after daemonization. Call Shutdown() if this function fails.
6264
* @pre Parameters should be parsed and config file should be read, AppInitLockDataDirectory should have been called.
6365
*/
64-
bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info = nullptr);
66+
bool AppInitMain(node::NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info = nullptr);
6567

6668
/**
6769
* Register all arguments with the ArgsManager

src/init/bitcoin-gui.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class BitcoinGuiInit : public interfaces::Init
3333
}
3434
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
3535
interfaces::Ipc* ipc() override { return m_ipc.get(); }
36-
NodeContext m_node;
36+
node::NodeContext m_node;
3737
std::unique_ptr<interfaces::Ipc> m_ipc;
3838
};
3939
} // namespace

src/init/bitcoin-node.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const char* EXE_NAME = "bitcoin-node";
2020
class BitcoinNodeInit : public interfaces::Init
2121
{
2222
public:
23-
BitcoinNodeInit(NodeContext& node, const char* arg0)
23+
BitcoinNodeInit(node::NodeContext& node, const char* arg0)
2424
: m_node(node),
2525
m_ipc(interfaces::MakeIpc(EXE_NAME, arg0, *this))
2626
{
@@ -35,14 +35,14 @@ class BitcoinNodeInit : public interfaces::Init
3535
}
3636
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
3737
interfaces::Ipc* ipc() override { return m_ipc.get(); }
38-
NodeContext& m_node;
38+
node::NodeContext& m_node;
3939
std::unique_ptr<interfaces::Ipc> m_ipc;
4040
};
4141
} // namespace
4242
} // namespace init
4343

4444
namespace interfaces {
45-
std::unique_ptr<Init> MakeNodeInit(NodeContext& node, int argc, char* argv[], int& exit_status)
45+
std::unique_ptr<Init> MakeNodeInit(node::NodeContext& node, int argc, char* argv[], int& exit_status)
4646
{
4747
auto init = std::make_unique<init::BitcoinNodeInit>(node, argc > 0 ? argv[0] : "");
4848
// Check if bitcoin-node is being invoked as an IPC server. If so, then

src/init/bitcoin-qt.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class BitcoinQtInit : public interfaces::Init
2929
return MakeWalletLoader(chain, *Assert(m_node.args));
3030
}
3131
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
32-
NodeContext m_node;
32+
node::NodeContext m_node;
3333
};
3434
} // namespace
3535
} // namespace init

src/init/bitcoind.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#include <memory>
1414

15+
using node::NodeContext;
16+
1517
namespace init {
1618
namespace {
1719
class BitcoindInit : public interfaces::Init

src/interfaces/chain.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ enum class RBFTransactionState;
2828
struct bilingual_str;
2929
struct CBlockLocator;
3030
struct FeeCalculation;
31+
namespace node {
3132
struct NodeContext;
33+
} // namespace node
3234

3335
namespace interfaces {
3436

@@ -316,7 +318,7 @@ class ChainClient
316318
};
317319

318320
//! Return implementation of Chain interface.
319-
std::unique_ptr<Chain> MakeChain(NodeContext& node);
321+
std::unique_ptr<Chain> MakeChain(node::NodeContext& node);
320322

321323
} // namespace interfaces
322324

src/interfaces/init.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
#include <memory>
99

10+
namespace node {
1011
struct NodeContext;
12+
} // namespace node
1113

1214
namespace interfaces {
1315
class Chain;
@@ -40,7 +42,7 @@ class Init
4042
//! status code to exit with. If this returns non-null, the caller can start up
4143
//! normally and use the Init object to spawn and connect to other processes
4244
//! while it is running.
43-
std::unique_ptr<Init> MakeNodeInit(NodeContext& node, int argc, char* argv[], int& exit_status);
45+
std::unique_ptr<Init> MakeNodeInit(node::NodeContext& node, int argc, char* argv[], int& exit_status);
4446

4547
//! Return implementation of Init interface for the wallet process.
4648
std::unique_ptr<Init> MakeWalletInit(int argc, char* argv[], int& exit_status);

src/interfaces/node.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ class proxyType;
3232
enum class SynchronizationState;
3333
enum class TransactionError;
3434
struct CNodeStateStats;
35-
struct NodeContext;
3635
struct bilingual_str;
36+
namespace node {
37+
struct NodeContext;
38+
} // namespace node
3739

3840
namespace interfaces {
3941
class Handler;
@@ -242,12 +244,12 @@ class Node
242244

243245
//! Get and set internal node context. Useful for testing, but not
244246
//! accessible across processes.
245-
virtual NodeContext* context() { return nullptr; }
246-
virtual void setContext(NodeContext* context) { }
247+
virtual node::NodeContext* context() { return nullptr; }
248+
virtual void setContext(node::NodeContext* context) { }
247249
};
248250

249251
//! Return implementation of Node interface.
250-
std::unique_ptr<Node> MakeNode(NodeContext& context);
252+
std::unique_ptr<Node> MakeNode(node::NodeContext& context);
251253

252254
//! Block tip (could be a header or not, depends on the subscribed signal).
253255
struct BlockTip {

src/net_processing.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
#include <optional>
4646
#include <typeinfo>
4747

48+
using node::ReadBlockFromDisk;
49+
using node::ReadRawBlockFromDisk;
50+
using node::fImporting;
51+
using node::fPruneMode;
52+
using node::fReindex;
53+
4854
/** How long to cache transactions in mapRelay for normal relay */
4955
static constexpr auto RELAY_TX_CACHE_TIME = 15min;
5056
/** How long a transaction has to be in the mempool before it can unconditionally be relayed (even when not in mapRelay). */

src/node/blockstorage.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <util/system.h>
2222
#include <validation.h>
2323

24+
namespace node {
2425
std::atomic_bool fImporting(false);
2526
std::atomic_bool fReindex(false);
2627
bool fHavePruned = false;
@@ -472,12 +473,14 @@ void CleanupBlockRevFiles()
472473
remove(item.second);
473474
}
474475
}
476+
} // namespace node
475477

476478
std::string CBlockFileInfo::ToString() const
477479
{
478480
return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, FormatISO8601Date(nTimeFirst), FormatISO8601Date(nTimeLast));
479481
}
480482

483+
namespace node {
481484
CBlockFileInfo* BlockManager::GetBlockFileInfo(size_t n)
482485
{
483486
LOCK(cs_LastBlockFile);
@@ -939,3 +942,4 @@ void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFile
939942
} // End scope of CImportingNow
940943
chainman.ActiveChainstate().LoadMempool(args);
941944
}
945+
} // namespace node

src/node/blockstorage.h

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace Consensus {
2929
struct Params;
3030
}
3131

32+
namespace node {
3233
static constexpr bool DEFAULT_STOPAFTERBLOCKIMPORT{false};
3334

3435
/** The pre-allocation chunk size for blk?????.dat files (since 0.8) */
@@ -185,5 +186,6 @@ bool ReadRawBlockFromDisk(std::vector<uint8_t>& block, const CBlockIndex* pindex
185186
bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex);
186187

187188
void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFiles, const ArgsManager& args);
189+
} // namespace node
188190

189191
#endif // BITCOIN_NODE_BLOCKSTORAGE_H

src/node/caches.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <util/system.h>
99
#include <validation.h>
1010

11+
namespace node {
1112
CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes)
1213
{
1314
int64_t nTotalCache = (args.GetIntArg("-dbcache", nDefaultDbCache) << 20);
@@ -30,3 +31,4 @@ CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes)
3031
sizes.coins = nTotalCache; // the rest goes to in-memory cache
3132
return sizes;
3233
}
34+
} // namespace node

src/node/caches.h

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
class ArgsManager;
1212

13+
namespace node {
1314
struct CacheSizes {
1415
int64_t block_tree_db;
1516
int64_t coins_db;
@@ -18,5 +19,6 @@ struct CacheSizes {
1819
int64_t filter_index;
1920
};
2021
CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes = 0);
22+
} // namespace node
2123

2224
#endif // BITCOIN_NODE_CACHES_H

src/node/chainstate.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <node/blockstorage.h>
99
#include <validation.h>
1010

11+
namespace node {
1112
std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
1213
ChainstateManager& chainman,
1314
CTxMemPool* mempool,
@@ -156,3 +157,4 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage
156157

157158
return std::nullopt;
158159
}
160+
} // namespace node

src/node/chainstate.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
#include <optional>
1111

1212
class ChainstateManager;
13-
namespace Consensus {
14-
struct Params;
15-
}
1613
class CTxMemPool;
14+
namespace Consensus {
15+
struct Params;
16+
} // namespace Consensus
1717

18+
namespace node {
1819
enum class ChainstateLoadingError {
1920
ERROR_LOADING_BLOCK_DB,
2021
ERROR_BAD_GENESIS_BLOCK,
@@ -81,5 +82,6 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage
8182
unsigned int check_blocks,
8283
unsigned int check_level,
8384
std::function<int64_t()> get_unix_time_seconds);
85+
} // namespace node
8486

8587
#endif // BITCOIN_NODE_CHAINSTATE_H

src/node/coin.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <txmempool.h>
99
#include <validation.h>
1010

11+
namespace node {
1112
void FindCoins(const NodeContext& node, std::map<COutPoint, Coin>& coins)
1213
{
1314
assert(node.mempool);
@@ -22,3 +23,4 @@ void FindCoins(const NodeContext& node, std::map<COutPoint, Coin>& coins)
2223
}
2324
}
2425
}
26+
} // namespace node

0 commit comments

Comments
 (0)