Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/bench/coin_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@

#include <set>

using node::NodeContext;
using wallet::AttemptSelection;
using wallet::CInputCoin;
using wallet::COutput;
using wallet::CWallet;
using wallet::CWalletTx;
using wallet::CoinEligibilityFilter;
using wallet::CoinSelectionParams;
using wallet::CreateDummyWalletDatabase;
using wallet::OutputGroup;
using wallet::SelectCoinsBnB;
using wallet::TxStateInactive;

static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector<std::unique_ptr<CWalletTx>>& wtxs)
{
static int nextLockTime = 0;
Expand Down
6 changes: 6 additions & 0 deletions src/bench/wallet_balance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@

#include <optional>

using wallet::CWallet;Add commentMore actions
using wallet::CreateMockWalletDatabase;
using wallet::DBErrors;
using wallet::GetBalance;
using wallet::WALLET_FLAG_DESCRIPTORS;

static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const bool add_mine, const uint32_t epoch_iters)
{
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
Expand Down
2 changes: 1 addition & 1 deletion src/bitcoin-wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ MAIN_FUNCTION
}

ECC_Start();
if (!WalletTool::ExecuteWalletToolFunc(args, command->command)) {
if (!wallet::WalletTool::ExecuteWalletToolFunc(args, command->command)) {
return EXIT_FAILURE;
}
ECC_Stop();
Expand Down
2 changes: 2 additions & 0 deletions src/bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <cstdio>
#include <functional>

using node::NodeContext;

const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
UrlDecodeFn* const URL_DECODE = urlDecode;

Expand Down
6 changes: 6 additions & 0 deletions src/chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <chain.h>
#include <util/time.h>

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

#include <tinyformat.h>

Expand Down
8 changes: 1 addition & 7 deletions src/dummywallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <walletinitinterface.h>

class ArgsManager;
class CWallet;

namespace interfaces {
class Chain;
Expand All @@ -26,7 +25,7 @@ class DummyWalletInit : public WalletInitInterface {
bool HasWalletSupport() const override {return false;}
void AddWalletOptions(ArgsManager& argsman) const override;
bool ParameterInteraction() const override {return true;}
void Construct(NodeContext& node) const override {LogPrintf("No wallet support compiled in!\n");}
void Construct(node::NodeContext& node) const override {LogPrintf("No wallet support compiled in!\n");}

// Dash Specific WalletInitInterface InitCoinJoinSettings
void AutoLockMasternodeCollaterals(interfaces::WalletLoader& wallet_loader) const override {}
Expand Down Expand Up @@ -87,11 +86,6 @@ std::unique_ptr<CoinJoin::Loader> MakeCoinJoinLoader(NodeContext& node)
throw std::logic_error("Wallet function called in non-wallet build.");
}

std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet)
{
throw std::logic_error("Wallet function called in non-wallet build.");
}

std::unique_ptr<WalletClient> MakeWalletLoader(Chain& chain, ArgsManager& args, NodeContext& node_context,
interfaces::CoinJoin::Loader& coinjoin_loader)
{
Expand Down
2 changes: 2 additions & 0 deletions src/index/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <validation.h>
#include <warnings.h>

using node::ReadBlockFromDisk;

constexpr uint8_t DB_BEST_BLOCK{'B'};

constexpr auto SYNC_LOG_INTERVAL{30s};
Expand Down
2 changes: 2 additions & 0 deletions src/index/blockfilterindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <node/blockstorage.h>
#include <serialize.h>

using node::UndoReadFromDisk;

/* The index database stores three items for each block: the disk location of the encoded filter,
* its dSHA256 hash, and the header. Those belonging to blocks on the active chain are indexed by
* height, and those belonging to blocks that have been reorganized out of the active chain are
Expand Down
6 changes: 6 additions & 0 deletions src/index/coinstatsindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
#include <validation.h>
#include <util/check.h>

using node::CCoinsStats;
using node::GetBogoSize;
using node::ReadBlockFromDisk;
using node::TxOutSer;
using node::UndoReadFromDisk;

static constexpr uint8_t DB_BLOCK_HASH{'s'};
static constexpr uint8_t DB_BLOCK_HEIGHT{'t'};
static constexpr uint8_t DB_MUHASH{'M'};
Expand Down
2 changes: 1 addition & 1 deletion src/index/coinstatsindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class CoinStatsIndex final : public BaseIndex
explicit CoinStatsIndex(size_t n_cache_size, bool f_memory = false, bool f_wipe = false);

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

/// The global UTXO set hash object.
Expand Down
2 changes: 2 additions & 0 deletions src/index/txindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <util/system.h>
#include <validation.h>

using node::OpenBlockFile;

constexpr uint8_t DB_TXINDEX{'t'};

std::unique_ptr<TxIndex> g_txindex;
Expand Down
17 changes: 16 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,23 @@
static constexpr bool DEFAULT_PROXYRANDOMIZE{true};
static constexpr bool DEFAULT_REST_ENABLE{false};
static constexpr bool DEFAULT_I2P_ACCEPT_INCOMING{true};
using node::CacheSizes;
using node::CalculateCacheSizes;
using node::ChainstateLoadVerifyError;
using node::ChainstateLoadingError;
using node::CleanupBlockRevFiles;
using node::DEFAULT_PRINTPRIORITY;
using node::DEFAULT_STOPAFTERBLOCKIMPORT;
using node::LoadChainstate;
using node::NodeContext;
using node::ThreadImport;
using node::VerifyLoadedChainstate;
using node::fHavePruned;
using node::fPruneMode;
using node::fReindex;
using node::nPruneTarget;


#ifdef WIN32
// Win32 LevelDB doesn't use filedescriptors, and the ones used for
// accessing block files don't count towards the fd_set size limit
// anyway.
Expand Down
15 changes: 8 additions & 7 deletions src/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ static constexpr bool DEFAULT_DAEMON = false;
static constexpr bool DEFAULT_DAEMONWAIT = false;

class ArgsManager;
struct NodeContext;
namespace interfaces {
struct BlockAndHeaderTipInfo;
} // namespace interfaces

namespace node {
struct NodeContext;
} // namespace node
/** Interrupt threads */
void Interrupt(NodeContext& node);
void Shutdown(NodeContext& node);
void Interrupt(node::NodeContext& node);
void Shutdown(node::NodeContext& node);
//!Initialize the logging infrastructure
void InitLogging(const ArgsManager& args);
//!Parameter interaction: change current parameters depending on various rules
Expand Down Expand Up @@ -56,14 +57,14 @@ bool AppInitLockDataDirectory();
/**
* Initialize node and wallet interface pointers. Has no prerequisites or side effects besides allocating memory.
*/
bool AppInitInterfaces(NodeContext& node);
bool AppInitInterfaces(node::NodeContext& node);
/**
* Dash Core main initialization.
* @note This should only be done after daemonization. Call Shutdown() if this function fails.
* @pre Parameters should be parsed and config file should be read, AppInitLockDataDirectory should have been called.
*/
bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info = nullptr);
void PrepareShutdown(NodeContext& node);
bool AppInitMain(node::NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info = nullptr);
void PrepareShutdown(node::NodeContext& node);

/**
* Register all arguments with the ArgsManager
Expand Down
6 changes: 3 additions & 3 deletions src/init/bitcoin-node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const char* EXE_NAME = "dash-node";
class BitcoinNodeInit : public interfaces::Init
{
public:
BitcoinNodeInit(NodeContext& node, const char* arg0)
BitcoinNodeInit(node::NodeContext& node, const char* arg0)
: m_node(node),
m_ipc(interfaces::MakeIpc(EXE_NAME, arg0, *this))
{
Expand All @@ -41,14 +41,14 @@ class BitcoinNodeInit : public interfaces::Init
}
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
interfaces::Ipc* ipc() override { return m_ipc.get(); }
NodeContext& m_node;
node::NodeContext& m_node;
std::unique_ptr<interfaces::Ipc> m_ipc;
};
} // namespace
} // namespace init

namespace interfaces {
std::unique_ptr<Init> MakeNodeInit(NodeContext& node, int argc, char* argv[], int& exit_status)
std::unique_ptr<Init> MakeNodeInit(node::NodeContext& node, int argc, char* argv[], int& exit_status)
{
auto init = std::make_unique<init::BitcoinNodeInit>(node, argc > 0 ? argv[0] : "");
// Check if bitcoin-node is being invoked as an IPC server. If so, then
Expand Down
2 changes: 2 additions & 0 deletions src/init/bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include <memory>

using node::NodeContext;

namespace init {
namespace {
class BitcoindInit : public interfaces::Init
Expand Down
4 changes: 3 additions & 1 deletion src/interfaces/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ enum class MemPoolRemovalReason;
struct bilingual_str;
struct CBlockLocator;
struct FeeCalculation;
namespace node {
struct NodeContext;
}
enum class MemPoolRemovalReason;

namespace llmq {
Expand Down Expand Up @@ -339,7 +341,7 @@ class ChainClient
};

//! Return implementation of Chain interface.
std::unique_ptr<Chain> MakeChain(NodeContext& node);
std::unique_ptr<Chain> MakeChain(node::NodeContext& node);

} // namespace interfaces

Expand Down
4 changes: 3 additions & 1 deletion src/interfaces/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

#include <memory>

namespace node {
struct NodeContext;
} // namespace node

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

//! Return implementation of Init interface for the wallet process.
std::unique_ptr<Init> MakeWalletInit(int argc, char* argv[], int& exit_status);
Expand Down
15 changes: 10 additions & 5 deletions src/interfaces/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ struct bilingual_str;
enum class SynchronizationState;
enum class TransactionError;
struct CNodeStateStats;
namespace node {
struct NodeContext;
} // namespace node
namespace wallet {
class CCoinControl;
} // namespace wallet

enum vote_signal_enum_t : int;

Expand All @@ -55,7 +60,7 @@ class EVO
public:
virtual ~EVO() {}
virtual std::pair<CDeterministicMNList, const CBlockIndex*> getListAtChainTip() = 0;
virtual void setContext(NodeContext* context) {}
virtual void setContext(node::NodeContext* context) {}
};

//! Interface for the src/governance part of a dash node (dashd process).
Expand All @@ -67,7 +72,7 @@ class GOV
virtual int32_t getObjAbsYesCount(const CGovernanceObject& obj, vote_signal_enum_t vote_signal) = 0;
virtual bool getObjLocalValidity(const CGovernanceObject& obj, std::string& error, bool check_collateral) = 0;
virtual bool isEnabled() = 0;
virtual void setContext(NodeContext* context) {}
virtual void setContext(node::NodeContext* context) {}
};

//! Interface for the src/llmq part of a dash node (dashd process).
Expand Down Expand Up @@ -354,12 +359,12 @@ class Node

//! Get and set internal node context. Useful for testing, but not
//! accessible across processes.
virtual NodeContext* context() { return nullptr; }
virtual void setContext(NodeContext* context) { }
virtual node::NodeContext* context() { return nullptr; }
virtual void setContext(node::NodeContext* context) { }
};

//! Return implementation of Node interface.
std::unique_ptr<Node> MakeNode(NodeContext& context);
std::unique_ptr<Node> MakeNode(node::NodeContext& context);

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