Skip to content

Commit c561f2f

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#23497: Add src/node/ and src/wallet/ code to node:: and wallet:: namespaces
e5b6aef Move CBlockFileInfo::ToString method where class is declared (Russell Yanofsky) f7086fd Add src/wallet/* code to wallet:: namespace (Russell Yanofsky) 90fc8b0 Add src/node/* code to node:: namespace (Russell Yanofsky) Pull request description: There are no code changes, this is just adding `namespace` and `using` declarations and `node::` or `wallet::` qualifiers in some places. Motivations for this change are: - To make it easier to see when node and wallet code is being accessed places where it shouldn't be. For example if GUI code is accessing node and wallet internals or if wallet and node code are referencing each other. - To make source code organization clearer ([#15732](bitcoin/bitcoin#15732)), being able to know that `wallet::` code is in `src/wallet/`, `node::` code is in `src/node/`, `init::` code is in `src/init/`, `util::` code is in `src/util/`, etc. Reviewing with `git log -p -n1 -U0 --word-diff-regex=.` can be helpful to verify this is only updating declarations, not changing code. ACKs for top commit: achow101: ACK e5b6aef MarcoFalke: Concept ACK e5b6aef 🍨 Tree-SHA512: 3797745c90246794e2d55a2ee6e8b0ad5c811e4e03a242d3fdfeb68032f8787f0d48ed4097f6b7730f540220c0af99ef423cd9dbe7f76b2ec12e769a757a2c8d
2 parents fa74718 + e5b6aef commit c561f2f

File tree

166 files changed

+580
-140
lines changed

Some content is hidden

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

166 files changed

+580
-140
lines changed

src/bench/coin_selection.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111

1212
#include <set>
1313

14+
using node::NodeContext;
15+
using wallet::AttemptSelection;
16+
using wallet::CInputCoin;
17+
using wallet::COutput;
18+
using wallet::CWallet;
19+
using wallet::CWalletTx;
20+
using wallet::CoinEligibilityFilter;
21+
using wallet::CoinSelectionParams;
22+
using wallet::CreateDummyWalletDatabase;
23+
using wallet::OutputGroup;
24+
using wallet::SelectCoinsBnB;
25+
using wallet::TxStateInactive;
26+
1427
static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector<std::unique_ptr<CWalletTx>>& wtxs)
1528
{
1629
static int nextLockTime = 0;

src/bench/wallet_balance.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414

1515
#include <optional>
1616

17+
using wallet::CWallet;
18+
using wallet::CreateMockWalletDatabase;
19+
using wallet::DBErrors;
20+
using wallet::GetBalance;
21+
using wallet::WALLET_FLAG_DESCRIPTORS;
22+
1723
static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const bool add_mine)
1824
{
1925
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();

src/bitcoin-wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ int main(int argc, char* argv[])
123123

124124
ECCVerifyHandle globalVerifyHandle;
125125
ECC_Start();
126-
if (!WalletTool::ExecuteWalletToolFunc(args, command->command)) {
126+
if (!wallet::WalletTool::ExecuteWalletToolFunc(args, command->command)) {
127127
return EXIT_FAILURE;
128128
}
129129
ECC_Stop();

src/bitcoind.cpp

Lines changed: 2 additions & 0 deletions
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/chain.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

66
#include <chain.h>
7+
#include <util/time.h>
8+
9+
std::string CBlockFileInfo::ToString() const
10+
{
11+
return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, FormatISO8601Date(nTimeFirst), FormatISO8601Date(nTimeLast));
12+
}
713

814
void CChain::SetTip(CBlockIndex *pindex) {
915
if (pindex == nullptr) {

src/dummywallet.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <walletinitinterface.h>
77

88
class ArgsManager;
9-
class CWallet;
109

1110
namespace interfaces {
1211
class Chain;
@@ -21,7 +20,7 @@ class DummyWalletInit : public WalletInitInterface {
2120
bool HasWalletSupport() const override {return false;}
2221
void AddWalletOptions(ArgsManager& argsman) const override;
2322
bool ParameterInteraction() const override {return true;}
24-
void Construct(NodeContext& node) const override {LogPrintf("No wallet support compiled in!\n");}
23+
void Construct(node::NodeContext& node) const override {LogPrintf("No wallet support compiled in!\n");}
2524
};
2625

2726
void DummyWalletInit::AddWalletOptions(ArgsManager& argsman) const
@@ -59,11 +58,6 @@ const WalletInitInterface& g_wallet_init_interface = DummyWalletInit();
5958

6059
namespace interfaces {
6160

62-
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet)
63-
{
64-
throw std::logic_error("Wallet function called in non-wallet build.");
65-
}
66-
6761
std::unique_ptr<WalletLoader> MakeWalletLoader(Chain& chain, ArgsManager& args)
6862
{
6963
throw std::logic_error("Wallet function called in non-wallet build.");

src/index/base.cpp

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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.

0 commit comments

Comments
 (0)