Page MenuHomePhabricator

D12763.id36990.diff
No OneTemporary

D12763.id36990.diff

diff --git a/src/bench/coin_selection.cpp b/src/bench/coin_selection.cpp
--- a/src/bench/coin_selection.cpp
+++ b/src/bench/coin_selection.cpp
@@ -13,6 +13,8 @@
#include <memory>
#include <set>
+using node::NodeContext;
+
static void addCoin(const Amount nValue, const CWallet &wallet,
std::vector<std::unique_ptr<CWalletTx>> &wtxs) {
static int nextLockTime = 0;
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -28,6 +28,8 @@
#include <any>
#include <functional>
+using node::NodeContext;
+
const std::function<std::string(const char *)> G_TRANSLATION_FUN = nullptr;
#if HAVE_DECL_FORK
diff --git a/src/dummywallet.cpp b/src/dummywallet.cpp
--- a/src/dummywallet.cpp
+++ b/src/dummywallet.cpp
@@ -20,7 +20,7 @@
bool HasWalletSupport() const override { return false; }
void AddWalletOptions(ArgsManager &argsman) const override;
bool ParameterInteraction() const override { return true; }
- void Construct(NodeContext &node) const override {
+ void Construct(node::NodeContext &node) const override {
LogPrintf("No wallet support compiled in!\n");
}
};
diff --git a/src/index/base.cpp b/src/index/base.cpp
--- a/src/index/base.cpp
+++ b/src/index/base.cpp
@@ -17,6 +17,8 @@
#include <functional>
+using node::ReadBlockFromDisk;
+
constexpr char DB_BEST_BLOCK = 'B';
constexpr int64_t SYNC_LOG_INTERVAL = 30; // secon
diff --git a/src/index/blockfilterindex.cpp b/src/index/blockfilterindex.cpp
--- a/src/index/blockfilterindex.cpp
+++ b/src/index/blockfilterindex.cpp
@@ -10,6 +10,8 @@
#include <map>
+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
diff --git a/src/index/coinstatsindex.h b/src/index/coinstatsindex.h
--- a/src/index/coinstatsindex.h
+++ b/src/index/coinstatsindex.h
@@ -56,7 +56,7 @@
// Look up stats for a specific block using CBlockIndex
bool LookUpStats(const CBlockIndex *block_index,
- CCoinsStats &coins_stats) const;
+ node::CCoinsStats &coins_stats) const;
};
/// The global UTXO set hash object.
diff --git a/src/index/coinstatsindex.cpp b/src/index/coinstatsindex.cpp
--- a/src/index/coinstatsindex.cpp
+++ b/src/index/coinstatsindex.cpp
@@ -16,6 +16,12 @@
#include <util/check.h>
#include <validation.h>
+using node::CCoinsStats;
+using node::GetBogoSize;
+using node::ReadBlockFromDisk;
+using node::TxOutSer;
+using node::UndoReadFromDisk;
+
static constexpr char DB_BLOCK_HASH = 's';
static constexpr char DB_BLOCK_HEIGHT = 't';
static constexpr char DB_MUHASH = 'M';
diff --git a/src/index/txindex.cpp b/src/index/txindex.cpp
--- a/src/index/txindex.cpp
+++ b/src/index/txindex.cpp
@@ -10,6 +10,8 @@
#include <util/system.h>
#include <validation.h>
+using node::OpenBlockFile;
+
constexpr char DB_TXINDEX = 't';
std::unique_ptr<TxIndex> g_txindex;
diff --git a/src/init.h b/src/init.h
--- a/src/init.h
+++ b/src/init.h
@@ -22,15 +22,17 @@
class CScheduler;
class CWallet;
class HTTPRPCRequestProcessor;
-struct NodeContext;
namespace interfaces {
struct BlockAndHeaderTipInfo;
}
+namespace node {
+struct NodeContext;
+} // namespace node
class RPCServer;
/** 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
@@ -71,7 +73,7 @@
* Initialize node and wallet interface pointers. Has no prerequisites or side
* effects besides allocating memory.
*/
-bool AppInitInterfaces(NodeContext &node);
+bool AppInitInterfaces(node::NodeContext &node);
/**
* Bitcoin main initialization.
* @note This should only be done after daemonization.
@@ -80,13 +82,13 @@
*/
bool AppInitMain(Config &config, RPCServer &rpcServer,
HTTPRPCRequestProcessor &httpRPCRequestProcessor,
- NodeContext &node,
+ node::NodeContext &node,
interfaces::BlockAndHeaderTipInfo *tip_info = nullptr);
/**
* Register all arguments with the ArgsManager
*/
-void SetupServerArgs(NodeContext &node);
+void SetupServerArgs(node::NodeContext &node);
/** Returns licensing information (for -version) */
std::string LicenseInfo();
diff --git a/src/init.cpp b/src/init.cpp
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -100,6 +100,21 @@
#include <thread>
#include <vector>
+using node::CacheSizes;
+using node::CalculateCacheSizes;
+using node::ChainstateLoadingError;
+using node::ChainstateLoadVerifyError;
+using node::CleanupBlockRevFiles;
+using node::DEFAULT_STOPAFTERBLOCKIMPORT;
+using node::fHavePruned;
+using node::fPruneMode;
+using node::fReindex;
+using node::LoadChainstate;
+using node::NodeContext;
+using node::nPruneTarget;
+using node::ThreadImport;
+using node::VerifyLoadedChainstate;
+
static const bool DEFAULT_PROXYRANDOMIZE = true;
static const bool DEFAULT_REST_ENABLE = false;
diff --git a/src/init/common.cpp b/src/init/common.cpp
--- a/src/init/common.cpp
+++ b/src/init/common.cpp
@@ -21,6 +21,8 @@
#include <memory>
+using node::DEFAULT_PRINTPRIORITY;
+
static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle;
namespace init {
diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h
--- a/src/interfaces/chain.h
+++ b/src/interfaces/chain.h
@@ -31,7 +31,9 @@
struct BlockHash;
struct bilingual_str;
struct CBlockLocator;
+namespace node {
struct NodeContext;
+} // namespace node
namespace Consensus {
struct Params;
@@ -350,7 +352,8 @@
};
//! Return implementation of Chain interface.
-std::unique_ptr<Chain> MakeChain(NodeContext &node, const CChainParams &params);
+std::unique_ptr<Chain> MakeChain(node::NodeContext &node,
+ const CChainParams &params);
} // namespace interfaces
diff --git a/src/interfaces/node.h b/src/interfaces/node.h
--- a/src/interfaces/node.h
+++ b/src/interfaces/node.h
@@ -29,13 +29,15 @@
class Coin;
class Config;
class HTTPRPCRequestProcessor;
-struct NodeContext;
class proxyType;
class RPCServer;
class RPCTimerInterface;
enum class SynchronizationState;
class UniValue;
struct bilingual_str;
+namespace node {
+struct NodeContext;
+} // namespace node
namespace interfaces {
class Handler;
@@ -238,12 +240,12 @@
//! 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 = nullptr);
+std::unique_ptr<Node> MakeNode(node::NodeContext *context = nullptr);
//! Block tip (could be a header or not, depends on the subscribed signal).
struct BlockTip {
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -50,6 +50,11 @@
#include <memory>
#include <typeinfo>
+using node::fImporting;
+using node::fPruneMode;
+using node::fReindex;
+using node::ReadBlockFromDisk;
+
/** How long to cache transactions in mapRelay for normal relay */
static constexpr auto RELAY_TX_CACHE_TIME = 15min;
/**
diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h
--- a/src/node/blockstorage.h
+++ b/src/node/blockstorage.h
@@ -30,6 +30,7 @@
struct Params;
}
+namespace node {
static constexpr bool DEFAULT_STOPAFTERBLOCKIMPORT{false};
/** The pre-allocation chunk size for blk?????.dat files (since 0.8) */
@@ -208,5 +209,6 @@
void ThreadImport(const Config &config, ChainstateManager &chainman,
std::vector<fs::path> vImportFiles, const ArgsManager &args);
+} // namespace node
#endif // BITCOIN_NODE_BLOCKSTORAGE_H
diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp
--- a/src/node/blockstorage.cpp
+++ b/src/node/blockstorage.cpp
@@ -21,6 +21,7 @@
#include <util/system.h>
#include <validation.h>
+namespace node {
std::atomic_bool fImporting(false);
std::atomic_bool fReindex(false);
bool fHavePruned = false;
@@ -520,6 +521,7 @@
remove(item.second);
}
}
+} // namespace node
std::string CBlockFileInfo::ToString() const {
return strprintf(
@@ -528,6 +530,7 @@
FormatISO8601DateTime(nTimeFirst), FormatISO8601DateTime(nTimeLast));
}
+namespace node {
CBlockFileInfo *BlockManager::GetBlockFileInfo(size_t n) {
LOCK(cs_LastBlockFile);
@@ -1009,3 +1012,4 @@
} // End scope of CImportingNow
chainman.ActiveChainstate().LoadMempool(config, args);
}
+} // namespace node
diff --git a/src/node/caches.h b/src/node/caches.h
--- a/src/node/caches.h
+++ b/src/node/caches.h
@@ -10,6 +10,7 @@
class ArgsManager;
+namespace node {
struct CacheSizes {
int64_t block_tree_db;
int64_t coins_db;
@@ -18,5 +19,6 @@
int64_t filter_index;
};
CacheSizes CalculateCacheSizes(const ArgsManager &args, size_t n_indexes = 0);
+} // namespace node
#endif // BITCOIN_NODE_CACHES_H
diff --git a/src/node/caches.cpp b/src/node/caches.cpp
--- a/src/node/caches.cpp
+++ b/src/node/caches.cpp
@@ -8,6 +8,7 @@
#include <util/system.h>
#include <validation.h>
+namespace node {
CacheSizes CalculateCacheSizes(const ArgsManager &args, size_t n_indexes) {
int64_t nTotalCache =
(args.GetIntArg("-dbcache", DEFAULT_DB_CACHE_MB) << 20);
@@ -44,3 +45,4 @@
return sizes;
}
+} // namespace node
diff --git a/src/node/chainstate.h b/src/node/chainstate.h
--- a/src/node/chainstate.h
+++ b/src/node/chainstate.h
@@ -12,11 +12,12 @@
struct bilingual_str;
class Config;
class ChainstateManager;
+class CTxMemPool;
namespace Consensus {
struct Params;
-}
-class CTxMemPool;
+} // namespace Consensus
+namespace node {
enum class ChainstateLoadingError {
ERROR_UPGRADING_BLOCK_DB,
ERROR_LOADING_BLOCK_DB,
@@ -77,5 +78,6 @@
bool fReindexChainState, const Config &config,
unsigned int check_blocks, unsigned int check_level,
std::function<int64_t()> get_unix_time_seconds);
+} // namespace node
#endif // BITCOIN_NODE_CHAINSTATE_H
diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp
--- a/src/node/chainstate.cpp
+++ b/src/node/chainstate.cpp
@@ -9,6 +9,7 @@
#include <node/blockstorage.h>
#include <validation.h>
+namespace node {
std::optional<ChainstateLoadingError>
LoadChainstate(bool fReset, ChainstateManager &chainman, CTxMemPool *mempool,
bool fPruneMode_, const Consensus::Params &consensus_params,
@@ -163,3 +164,4 @@
return std::nullopt;
}
+} // namespace node
diff --git a/src/node/coin.h b/src/node/coin.h
--- a/src/node/coin.h
+++ b/src/node/coin.h
@@ -9,6 +9,8 @@
class COutPoint;
class Coin;
+
+namespace node {
struct NodeContext;
/**
@@ -20,5 +22,6 @@
* @param[in,out] coins map to fill
*/
void FindCoins(const NodeContext &node, std::map<COutPoint, Coin> &coins);
+} // namespace node
#endif // BITCOIN_NODE_COIN_H
diff --git a/src/node/coin.cpp b/src/node/coin.cpp
--- a/src/node/coin.cpp
+++ b/src/node/coin.cpp
@@ -8,6 +8,7 @@
#include <txmempool.h>
#include <validation.h>
+namespace node {
void FindCoins(const NodeContext &node, std::map<COutPoint, Coin> &coins) {
assert(node.mempool);
assert(node.chainman);
@@ -22,3 +23,4 @@
}
}
}
+} // namespace node
diff --git a/src/node/coinstats.h b/src/node/coinstats.h
--- a/src/node/coinstats.h
+++ b/src/node/coinstats.h
@@ -16,9 +16,12 @@
#include <cstdint>
#include <functional>
-class BlockManager;
class CCoinsView;
+namespace node {
+class BlockManager;
+} // namespace node
+namespace node {
enum class CoinStatsHashType {
HASH_SERIALIZED,
MUHASH,
@@ -59,12 +62,14 @@
};
//! Calculate statistics about the unspent transaction output set
-bool GetUTXOStats(CCoinsView *view, BlockManager &blockman, CCoinsStats &stats,
+bool GetUTXOStats(CCoinsView *view, node::BlockManager &blockman,
+ CCoinsStats &stats,
const std::function<void()> &interruption_point = {},
const CBlockIndex *pindex = nullptr);
uint64_t GetBogoSize(const CScript &script_pub_key);
CDataStream TxOutSer(const COutPoint &outpoint, const Coin &coin);
+} // namespace node
#endif // BITCOIN_NODE_COINSTATS_H
diff --git a/src/node/coinstats.cpp b/src/node/coinstats.cpp
--- a/src/node/coinstats.cpp
+++ b/src/node/coinstats.cpp
@@ -17,6 +17,7 @@
#include <map>
+namespace node {
uint64_t GetBogoSize(const CScript &script_pub_key) {
return 32 /* txid */ + 4 /* vout index */ + 4 /* height + coinbase */ +
8 /* amount */ + 2 /* scriptPubKey len */ +
@@ -182,3 +183,4 @@
stats.hashSerialized = out;
}
static void FinalizeHash(std::nullptr_t, CCoinsStats &stats) {}
+} // namespace node
diff --git a/src/node/context.h b/src/node/context.h
--- a/src/node/context.h
+++ b/src/node/context.h
@@ -24,6 +24,7 @@
class WalletClient;
} // namespace interfaces
+namespace node {
//! NodeContext struct containing references to chain state and connection
//! state.
//!
@@ -59,5 +60,6 @@
NodeContext();
~NodeContext();
};
+} // namespace node
#endif // BITCOIN_NODE_CONTEXT_H
diff --git a/src/node/context.cpp b/src/node/context.cpp
--- a/src/node/context.cpp
+++ b/src/node/context.cpp
@@ -13,5 +13,7 @@
#include <txmempool.h>
#include <validation.h>
+namespace node {
NodeContext::NodeContext() {}
NodeContext::~NodeContext() {}
+} // namespace node
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -226,8 +226,8 @@
bool isInitialBlockDownload() override {
return chainman().ActiveChainstate().IsInitialBlockDownload();
}
- bool getReindex() override { return ::fReindex; }
- bool getImporting() override { return ::fImporting; }
+ bool getReindex() override { return node::fReindex; }
+ bool getImporting() override { return node::fImporting; }
void setNetworkActive(bool active) override {
if (m_context->connman) {
m_context->connman->SetNetworkActive(active);
@@ -683,10 +683,11 @@
CFeeRate relayDustFee() override { return ::dustRelayFee; }
bool havePruned() override {
LOCK(cs_main);
- return ::fHavePruned;
+ return node::fHavePruned;
}
bool isReadyToBroadcast() override {
- return !::fImporting && !::fReindex && !isInitialBlockDownload();
+ return !node::fImporting && !node::fReindex &&
+ !isInitialBlockDownload();
}
bool isInitialBlockDownload() override {
return chainman().ActiveChainstate().IsInitialBlockDownload();
@@ -774,10 +775,10 @@
} // namespace node
namespace interfaces {
-std::unique_ptr<Node> MakeNode(NodeContext *context) {
+std::unique_ptr<Node> MakeNode(node::NodeContext *context) {
return std::make_unique<node::NodeImpl>(context);
}
-std::unique_ptr<Chain> MakeChain(NodeContext &node,
+std::unique_ptr<Chain> MakeChain(node::NodeContext &node,
const CChainParams &params) {
return std::make_unique<node::ChainImpl>(node, params);
}
diff --git a/src/node/miner.h b/src/node/miner.h
--- a/src/node/miner.h
+++ b/src/node/miner.h
@@ -26,6 +26,7 @@
struct Params;
}
+namespace node {
static const bool DEFAULT_PRINTPRIORITY = false;
struct CBlockTemplateEntry {
@@ -234,4 +235,6 @@
unsigned int &nExtraNonce);
int64_t UpdateTime(CBlockHeader *pblock, const CChainParams &chainParams,
const CBlockIndex *pindexPrev);
+} // namespace node
+
#endif // BITCOIN_NODE_MINER_H
diff --git a/src/node/miner.cpp b/src/node/miner.cpp
--- a/src/node/miner.cpp
+++ b/src/node/miner.cpp
@@ -29,6 +29,7 @@
#include <algorithm>
#include <utility>
+namespace node {
int64_t UpdateTime(CBlockHeader *pblock, const CChainParams &chainParams,
const CBlockIndex *pindexPrev) {
int64_t nOldTime = pblock->nTime;
@@ -578,3 +579,4 @@
pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase));
pblock->hashMerkleRoot = BlockMerkleRoot(*pblock);
}
+} // namespace node
diff --git a/src/node/psbt.h b/src/node/psbt.h
--- a/src/node/psbt.h
+++ b/src/node/psbt.h
@@ -9,6 +9,7 @@
#include <optional>
+namespace node {
/**
* Holds an analysis of one input from a PSBT
*/
@@ -63,5 +64,6 @@
* @return A PSBTAnalysis with information about the provided PSBT.
*/
PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx);
+} // namespace node
#endif // BITCOIN_NODE_PSBT_H
diff --git a/src/node/psbt.cpp b/src/node/psbt.cpp
--- a/src/node/psbt.cpp
+++ b/src/node/psbt.cpp
@@ -12,6 +12,7 @@
#include <numeric>
+namespace node {
PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx) {
// Go through each input and build status
PSBTAnalysis result;
@@ -158,3 +159,4 @@
return result;
}
+} // namespace node
diff --git a/src/node/transaction.h b/src/node/transaction.h
--- a/src/node/transaction.h
+++ b/src/node/transaction.h
@@ -14,13 +14,15 @@
class CBlockIndex;
class Config;
class CTxMemPool;
-struct NodeContext;
struct TxId;
namespace Consensus {
struct Params;
}
+namespace node {
+struct NodeContext;
+
/**
* Maximum fee rate for sendrawtransaction and testmempoolaccept RPC calls.
* Also used by the GUI when broadcasting a completed PSBT.
@@ -77,5 +79,6 @@
const TxId &txid,
const Consensus::Params &consensusParams,
BlockHash &hashBlock);
+} // namespace node
#endif // BITCOIN_NODE_TRANSACTION_H
diff --git a/src/node/transaction.cpp b/src/node/transaction.cpp
--- a/src/node/transaction.cpp
+++ b/src/node/transaction.cpp
@@ -20,6 +20,7 @@
#include <future>
+namespace node {
static TransactionError HandleATMPError(const TxValidationState &state,
std::string &err_string_out) {
err_string_out = state.ToString();
@@ -163,3 +164,4 @@
}
return nullptr;
}
+} // namespace node
diff --git a/src/node/utxo_snapshot.h b/src/node/utxo_snapshot.h
--- a/src/node/utxo_snapshot.h
+++ b/src/node/utxo_snapshot.h
@@ -9,6 +9,7 @@
#include <primitives/blockhash.h>
#include <serialize.h>
+namespace node {
//! Metadata describing a serialized version of a UTXO set from which an
//! assumeutxo CChainState can be constructed.
class SnapshotMetadata {
@@ -30,5 +31,6 @@
READWRITE(obj.m_base_blockhash, obj.m_coins_count);
}
};
+} // namespace node
#endif // BITCOIN_NODE_UTXO_SNAPSHOT_H
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -70,6 +70,8 @@
// Config is non-copyable so we can only register pointers to it
Q_DECLARE_METATYPE(Config *)
+using node::NodeContext;
+
static void RegisterMetaTypes() {
// Register meta types used for QMetaObject::invokeMethod and
// Qt::QueuedConnection
diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp
--- a/src/qt/test/test_main.cpp
+++ b/src/qt/test/test_main.cpp
@@ -45,6 +45,8 @@
#endif
#endif
+using node::NodeContext;
+
// This is all you need to run all the tests
int main(int argc, char *argv[]) {
// Initialize persistent globals with the testing setup state for sanity.
diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp
--- a/src/qt/walletview.cpp
+++ b/src/qt/walletview.cpp
@@ -33,6 +33,10 @@
#include <QPushButton>
#include <QVBoxLayout>
+using node::AnalyzePSBT;
+using node::DEFAULT_MAX_RAW_TX_FEE_RATE;
+using node::PSBTAnalysis;
+
WalletView::WalletView(const PlatformStyle *_platformStyle,
WalletModel *_walletModel, QWidget *parent)
: QStackedWidget(parent), clientModel(nullptr), walletModel(_walletModel),
diff --git a/src/rest.cpp b/src/rest.cpp
--- a/src/rest.cpp
+++ b/src/rest.cpp
@@ -30,6 +30,11 @@
#include <any>
+using node::GetTransaction;
+using node::IsBlockPruned;
+using node::NodeContext;
+using node::ReadBlockFromDisk;
+
// Allow a max of 15 outpoints to be queried at once.
static const size_t MAX_GETUTXOS_OUTPOINTS = 15;
diff --git a/src/rpc/avalanche.cpp b/src/rpc/avalanche.cpp
--- a/src/rpc/avalanche.cpp
+++ b/src/rpc/avalanche.cpp
@@ -25,6 +25,9 @@
#include <univalue.h>
+using node::GetTransaction;
+using node::NodeContext;
+
static RPCHelpMan getavalanchekey() {
return RPCHelpMan{
"getavalanchekey",
diff --git a/src/rpc/blockchain.h b/src/rpc/blockchain.h
--- a/src/rpc/blockchain.h
+++ b/src/rpc/blockchain.h
@@ -18,7 +18,9 @@
class ChainstateManager;
class CTxMemPool;
class RPCHelpMan;
+namespace node {
struct NodeContext;
+} // namespace node
extern RecursiveMutex cs_main;
@@ -56,7 +58,7 @@
* Helper to create UTXO snapshots given a chainstate and a file handle.
* @return a UniValue map containing metadata about the snapshot.
*/
-UniValue CreateUTXOSnapshot(NodeContext &node, CChainState &chainstate,
+UniValue CreateUTXOSnapshot(node::NodeContext &node, CChainState &chainstate,
CAutoFile &afile);
#endif // BITCOIN_RPC_BLOCKCHAIN_H
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -47,6 +47,16 @@
#include <memory>
#include <mutex>
+using node::BlockManager;
+using node::CCoinsStats;
+using node::CoinStatsHashType;
+using node::GetUTXOStats;
+using node::IsBlockPruned;
+using node::NodeContext;
+using node::ReadBlockFromDisk;
+using node::SnapshotMetadata;
+using node::UndoReadFromDisk;
+
struct CUpdatedBlock {
BlockHash hash;
int height;
@@ -1242,7 +1252,7 @@
HelpExampleRpc("pruneblockchain", "1000")},
[&](const RPCHelpMan &self, const Config &config,
const JSONRPCRequest &request) -> UniValue {
- if (!fPruneMode) {
+ if (!node::fPruneMode) {
throw JSONRPCError(
RPC_MISC_ERROR,
"Cannot prune blocks because node is not in prune mode.");
@@ -1903,9 +1913,9 @@
obj.pushKV("chainwork", tip->nChainWork.GetHex());
obj.pushKV("size_on_disk",
chainman.m_blockman.CalculateCurrentUsage());
- obj.pushKV("pruned", fPruneMode);
+ obj.pushKV("pruned", node::fPruneMode);
- if (fPruneMode) {
+ if (node::fPruneMode) {
const CBlockIndex *block = tip;
CHECK_NONFATAL(block);
while (block->pprev && (block->pprev->nStatus.hasData())) {
@@ -1918,7 +1928,7 @@
bool automatic_pruning = (gArgs.GetIntArg("-prune", 0) != 1);
obj.pushKV("automatic_pruning", automatic_pruning);
if (automatic_pruning) {
- obj.pushKV("prune_target_size", nPruneTarget);
+ obj.pushKV("prune_target_size", node::nPruneTarget);
}
}
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -41,6 +41,12 @@
#include <cstdint>
+using node::BlockAssembler;
+using node::CBlockTemplate;
+using node::IncrementExtraNonce;
+using node::NodeContext;
+using node::UpdateTime;
+
/**
* Return average network hashes per second based on the last 'lookup' blocks,
* or from the last difficulty change if 'lookup' is nonpositive. If 'height' is
diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp
--- a/src/rpc/misc.cpp
+++ b/src/rpc/misc.cpp
@@ -34,6 +34,8 @@
#include <malloc.h>
#endif
+using node::NodeContext;
+
static RPCHelpMan validateaddress() {
return RPCHelpMan{
"validateaddress",
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -33,6 +33,8 @@
#include <univalue.h>
+using node::NodeContext;
+
static RPCHelpMan getconnectioncount() {
return RPCHelpMan{
"getconnectioncount",
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -47,6 +47,15 @@
#include <univalue.h>
+using node::AnalyzePSBT;
+using node::BroadcastTransaction;
+using node::DEFAULT_MAX_RAW_TX_FEE_RATE;
+using node::FindCoins;
+using node::GetTransaction;
+using node::NodeContext;
+using node::PSBTAnalysis;
+using node::ReadBlockFromDisk;
+
static void TxToJSON(const CTransaction &tx, const BlockHash &hashBlock,
UniValue &entry, CChainState &active_chainstate) {
// Call into TxToUniv() in bitcoin-common to decode the transaction hex.
diff --git a/src/rpc/server_util.h b/src/rpc/server_util.h
--- a/src/rpc/server_util.h
+++ b/src/rpc/server_util.h
@@ -10,15 +10,17 @@
class CConnman;
class ChainstateManager;
class CTxMemPool;
+namespace node {
struct NodeContext;
+} // namespace node
class PeerManager;
-NodeContext &EnsureAnyNodeContext(const std::any &context);
-CTxMemPool &EnsureMemPool(const NodeContext &node);
+node::NodeContext &EnsureAnyNodeContext(const std::any &context);
+CTxMemPool &EnsureMemPool(const node::NodeContext &node);
CTxMemPool &EnsureAnyMemPool(const std::any &context);
-ChainstateManager &EnsureChainman(const NodeContext &node);
+ChainstateManager &EnsureChainman(const node::NodeContext &node);
ChainstateManager &EnsureAnyChainman(const std::any &context);
-CConnman &EnsureConnman(const NodeContext &node);
-PeerManager &EnsurePeerman(const NodeContext &node);
+CConnman &EnsureConnman(const node::NodeContext &node);
+PeerManager &EnsurePeerman(const node::NodeContext &node);
#endif // BITCOIN_RPC_SERVER_UTIL_H
diff --git a/src/rpc/server_util.cpp b/src/rpc/server_util.cpp
--- a/src/rpc/server_util.cpp
+++ b/src/rpc/server_util.cpp
@@ -14,6 +14,8 @@
#include <any>
+using node::NodeContext;
+
NodeContext &EnsureAnyNodeContext(const std::any &context) {
auto node_context = util::AnyPtr<NodeContext>(context);
if (!node_context) {
diff --git a/src/test/blockfilter_index_tests.cpp b/src/test/blockfilter_index_tests.cpp
--- a/src/test/blockfilter_index_tests.cpp
+++ b/src/test/blockfilter_index_tests.cpp
@@ -16,6 +16,10 @@
#include <boost/test/unit_test.hpp>
+using node::BlockAssembler;
+using node::CBlockTemplate;
+using node::IncrementExtraNonce;
+
BOOST_AUTO_TEST_SUITE(blockfilter_index_tests)
struct BuildChainTestingSetup : public TestChain100Setup {
diff --git a/src/test/coinstatsindex_tests.cpp b/src/test/coinstatsindex_tests.cpp
--- a/src/test/coinstatsindex_tests.cpp
+++ b/src/test/coinstatsindex_tests.cpp
@@ -11,6 +11,9 @@
#include <chrono>
+using node::CCoinsStats;
+using node::CoinStatsHashType;
+
BOOST_AUTO_TEST_SUITE(coinstatsindex_tests)
BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup) {
diff --git a/src/test/fuzz/coins_view.cpp b/src/test/fuzz/coins_view.cpp
--- a/src/test/fuzz/coins_view.cpp
+++ b/src/test/fuzz/coins_view.cpp
@@ -26,6 +26,10 @@
#include <string>
#include <vector>
+using node::CCoinsStats;
+using node::CoinStatsHashType;
+using node::GetUTXOStats;
+
namespace {
const TestingSetup *g_setup;
const Coin EMPTY_COIN{};
diff --git a/src/test/fuzz/deserialize.cpp b/src/test/fuzz/deserialize.cpp
--- a/src/test/fuzz/deserialize.cpp
+++ b/src/test/fuzz/deserialize.cpp
@@ -33,6 +33,8 @@
#include <unistd.h>
#include <vector>
+using node::SnapshotMetadata;
+
void initialize() {
// Fuzzers using pubkey must hold an ECCVerifyHandle.
static const ECCVerifyHandle verify_handle;
diff --git a/src/test/fuzz/psbt.cpp b/src/test/fuzz/psbt.cpp
--- a/src/test/fuzz/psbt.cpp
+++ b/src/test/fuzz/psbt.cpp
@@ -16,6 +16,10 @@
#include <string>
#include <vector>
+using node::AnalyzePSBT;
+using node::PSBTAnalysis;
+using node::PSBTInputAnalysis;
+
void initialize() {
static const ECCVerifyHandle verify_handle;
}
diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp
--- a/src/test/miner_tests.cpp
+++ b/src/test/miner_tests.cpp
@@ -29,6 +29,11 @@
#include <memory>
+using node::BlockAssembler;
+using node::CBlockTemplate;
+using node::CBlockTemplateEntry;
+using node::IncrementExtraNonce;
+
namespace miner_tests {
struct MinerTestingSetup : public TestingSetup {
void TestPackageSelection(const CChainParams &chainparams,
diff --git a/src/test/util/blockfilter.cpp b/src/test/util/blockfilter.cpp
--- a/src/test/util/blockfilter.cpp
+++ b/src/test/util/blockfilter.cpp
@@ -8,6 +8,9 @@
#include <node/blockstorage.h>
#include <validation.h>
+using node::ReadBlockFromDisk;
+using node::UndoReadFromDisk;
+
bool ComputeFilter(BlockFilterType filter_type, const CBlockIndex *block_index,
BlockFilter &filter) {
CBlock block;
diff --git a/src/test/util/chainstate.h b/src/test/util/chainstate.h
--- a/src/test/util/chainstate.h
+++ b/src/test/util/chainstate.h
@@ -16,10 +16,10 @@
#include <boost/test/unit_test.hpp>
-const auto NoMalleation = [](CAutoFile &file, SnapshotMetadata &meta) {};
+const auto NoMalleation = [](CAutoFile &file, node::SnapshotMetadata &meta) {};
template <typename F = decltype(NoMalleation)>
-static bool CreateAndActivateUTXOSnapshot(NodeContext &node,
+static bool CreateAndActivateUTXOSnapshot(node::NodeContext &node,
const fs::path root,
F malleation = NoMalleation) {
// Write out a snapshot to the test's tempdir.
@@ -40,7 +40,7 @@
//
FILE *infile{fsbridge::fopen(snapshot_path, "rb")};
CAutoFile auto_infile{infile, SER_DISK, CLIENT_VERSION};
- SnapshotMetadata metadata;
+ node::SnapshotMetadata metadata;
auto_infile >> metadata;
malleation(auto_infile, metadata);
diff --git a/src/test/util/mining.h b/src/test/util/mining.h
--- a/src/test/util/mining.h
+++ b/src/test/util/mining.h
@@ -12,18 +12,21 @@
class Config;
class CScript;
class CTxIn;
+namespace node {
struct NodeContext;
+} // namespace node
/** Returns the generated coin */
-CTxIn MineBlock(const Config &config, const NodeContext &,
+CTxIn MineBlock(const Config &config, const node::NodeContext &,
const CScript &coinbase_scriptPubKey);
/** Prepare a block to be mined */
-std::shared_ptr<CBlock> PrepareBlock(const Config &config, const NodeContext &,
+std::shared_ptr<CBlock> PrepareBlock(const Config &config,
+ const node::NodeContext &,
const CScript &coinbase_scriptPubKey);
/** RPC-like helper function, returns the generated coin */
-CTxIn generatetoaddress(const Config &config, const NodeContext &,
+CTxIn generatetoaddress(const Config &config, const node::NodeContext &,
const std::string &address);
#endif // BITCOIN_TEST_UTIL_MINING_H
diff --git a/src/test/util/mining.cpp b/src/test/util/mining.cpp
--- a/src/test/util/mining.cpp
+++ b/src/test/util/mining.cpp
@@ -15,6 +15,9 @@
#include <util/check.h>
#include <validation.h>
+using node::BlockAssembler;
+using node::NodeContext;
+
CTxIn generatetoaddress(const Config &config, const NodeContext &node,
const std::string &address) {
const auto dest = DecodeDestination(address, config.GetChainParams());
diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h
--- a/src/test/util/setup_common.h
+++ b/src/test/util/setup_common.h
@@ -101,7 +101,7 @@
*/
struct BasicTestingSetup {
ECCVerifyHandle globalVerifyHandle;
- NodeContext m_node;
+ node::NodeContext m_node;
explicit BasicTestingSetup(
const std::string &chainName = CBaseChainParams::MAIN,
@@ -118,7 +118,7 @@
* initialization behaviour.
*/
struct ChainTestingSetup : public BasicTestingSetup {
- CacheSizes m_cache_sizes{};
+ node::CacheSizes m_cache_sizes{};
explicit ChainTestingSetup(
const std::string &chainName = CBaseChainParams::MAIN,
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -45,6 +45,14 @@
#include <functional>
#include <memory>
+using node::BlockAssembler;
+using node::CalculateCacheSizes;
+using node::fPruneMode;
+using node::fReindex;
+using node::IncrementExtraNonce;
+using node::LoadChainstate;
+using node::VerifyLoadedChainstate;
+
const std::function<std::string(const char *)> G_TRANSLATION_FUN = nullptr;
FastRandomContext g_insecure_rand_ctx;
diff --git a/src/test/validation_block_tests.cpp b/src/test/validation_block_tests.cpp
--- a/src/test/validation_block_tests.cpp
+++ b/src/test/validation_block_tests.cpp
@@ -20,6 +20,8 @@
#include <thread>
+using node::BlockAssembler;
+
namespace validation_block_tests {
struct MinerTestingSetup : public RegTestingSetup {
std::shared_ptr<CBlock> Block(const Config &config,
diff --git a/src/test/validation_chainstatemanager_tests.cpp b/src/test/validation_chainstatemanager_tests.cpp
--- a/src/test/validation_chainstatemanager_tests.cpp
+++ b/src/test/validation_chainstatemanager_tests.cpp
@@ -20,6 +20,8 @@
#include <boost/test/unit_test.hpp>
+using node::SnapshotMetadata;
+
BOOST_FIXTURE_TEST_SUITE(validation_chainstatemanager_tests, ChainTestingSetup)
//! Basic tests for ChainstateManager.
diff --git a/src/test/validation_flush_tests.cpp b/src/test/validation_flush_tests.cpp
--- a/src/test/validation_flush_tests.cpp
+++ b/src/test/validation_flush_tests.cpp
@@ -9,6 +9,8 @@
#include <boost/test/unit_test.hpp>
+using node::BlockManager;
+
BOOST_FIXTURE_TEST_SUITE(validation_flush_tests, ChainTestingSetup)
//! Test utilities for detecting when we need to flush the coins cache based
diff --git a/src/validation.h b/src/validation.h
--- a/src/validation.h
+++ b/src/validation.h
@@ -51,13 +51,15 @@
class CTxMemPool;
class CTxUndo;
class DisconnectedBlockTransactions;
-class SnapshotMetadata;
struct ChainTxData;
struct FlatFilePos;
struct PrecomputedTransactionData;
struct LockPoints;
struct AssumeutxoData;
+namespace node {
+class SnapshotMetadata;
+} // namespace node
namespace Consensus {
struct Params;
@@ -712,7 +714,7 @@
public:
//! Reference to a BlockManager instance which itself is shared across all
//! CChainState instances.
- BlockManager &m_blockman;
+ node::BlockManager &m_blockman;
/** Chain parameters for this chainstate */
const CChainParams &m_params;
@@ -723,7 +725,7 @@
ChainstateManager &m_chainman;
explicit CChainState(
- CTxMemPool *mempool, BlockManager &blockman,
+ CTxMemPool *mempool, node::BlockManager &blockman,
ChainstateManager &chainman,
std::optional<BlockHash> from_snapshot_blockhash = std::nullopt);
@@ -1119,14 +1121,14 @@
CBlockIndex *m_best_invalid;
CBlockIndex *m_best_parked;
- friend bool BlockManager::LoadBlockIndex(const Consensus::Params &,
- ChainstateManager &);
+ friend bool node::BlockManager::LoadBlockIndex(const Consensus::Params &,
+ ChainstateManager &);
//! Internal helper for ActivateSnapshot().
[[nodiscard]] bool
PopulateAndValidateSnapshot(CChainState &snapshot_chainstate,
CAutoFile &coins_file,
- const SnapshotMetadata &metadata);
+ const node::SnapshotMetadata &metadata);
/**
* If a block header hasn't already been seen, call CheckBlockHeader on it,
* ensure that it doesn't descend from an invalid block, and then add it to
@@ -1141,7 +1143,7 @@
std::thread m_load_block;
//! A single BlockManager instance is shared across each constructed
//! chainstate to avoid duplicating block metadata.
- BlockManager m_blockman GUARDED_BY(::cs_main);
+ node::BlockManager m_blockman GUARDED_BY(::cs_main);
/**
* In order to efficiently track invalidity of headers, we keep the set of
@@ -1202,7 +1204,7 @@
//! - Move the new chainstate to `m_snapshot_chainstate` and make it our
//! ActiveChainstate().
[[nodiscard]] bool ActivateSnapshot(CAutoFile &coins_file,
- const SnapshotMetadata &metadata,
+ const node::SnapshotMetadata &metadata,
bool in_memory);
//! The most-work chain.
@@ -1211,7 +1213,7 @@
int ActiveHeight() const { return ActiveChain().Height(); }
CBlockIndex *ActiveTip() const { return ActiveChain().Tip(); }
- BlockMap &BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
+ node::BlockMap &BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
return m_blockman.m_block_index;
}
diff --git a/src/validation.cpp b/src/validation.cpp
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -63,6 +63,24 @@
#include <string>
#include <thread>
+using node::BLOCKFILE_CHUNK_SIZE;
+using node::BlockManager;
+using node::BlockMap;
+using node::CCoinsStats;
+using node::CoinStatsHashType;
+using node::fHavePruned;
+using node::fImporting;
+using node::fPruneMode;
+using node::fReindex;
+using node::GetUTXOStats;
+using node::nPruneTarget;
+using node::OpenBlockFile;
+using node::ReadBlockFromDisk;
+using node::SnapshotMetadata;
+using node::UNDOFILE_CHUNK_SIZE;
+using node::UndoReadFromDisk;
+using node::UnlinkPrunedFiles;
+
#define MICRO 0.000001
#define MILLI 0.001
diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp
--- a/src/wallet/init.cpp
+++ b/src/wallet/init.cpp
@@ -21,6 +21,8 @@
#include <wallet/wallet.h>
#include <walletinitinterface.h>
+using node::NodeContext;
+
class WalletInit : public WalletInitInterface {
public:
//! Was the wallet component compiled in.
diff --git a/src/wallet/test/coinselector_tests.cpp b/src/wallet/test/coinselector_tests.cpp
--- a/src/wallet/test/coinselector_tests.cpp
+++ b/src/wallet/test/coinselector_tests.cpp
@@ -33,7 +33,7 @@
typedef std::set<CInputCoin> CoinSet;
static std::vector<COutput> vCoins;
-static NodeContext testNode;
+static node::NodeContext testNode;
static Amount balance = Amount::zero();
CoinEligibilityFilter filter_standard(1, 6, 0);
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp
--- a/src/wallet/test/wallet_tests.cpp
+++ b/src/wallet/test/wallet_tests.cpp
@@ -30,6 +30,9 @@
#include <memory>
#include <vector>
+using node::MAX_BLOCKFILE_SIZE;
+using node::UnlinkPrunedFiles;
+
extern RecursiveMutex cs_wallets;
BOOST_FIXTURE_TEST_SUITE(wallet_tests, WalletTestingSetup)
diff --git a/src/wallet/test/walletdb_tests.cpp b/src/wallet/test/walletdb_tests.cpp
--- a/src/wallet/test/walletdb_tests.cpp
+++ b/src/wallet/test/walletdb_tests.cpp
@@ -18,7 +18,7 @@
namespace {
static std::unique_ptr<CWallet> LoadWallet(WalletBatch &batch) {
- NodeContext node;
+ node::NodeContext node;
auto chain = interfaces::MakeChain(node, Params());
std::unique_ptr<CWallet> wallet =
std::make_unique<CWallet>(chain.get(), "", CreateDummyWalletDatabase());
diff --git a/src/walletinitinterface.h b/src/walletinitinterface.h
--- a/src/walletinitinterface.h
+++ b/src/walletinitinterface.h
@@ -7,7 +7,9 @@
class ArgsManager;
+namespace node {
struct NodeContext;
+} // namespace node
class WalletInitInterface {
public:
@@ -18,7 +20,7 @@
/** Check wallet parameter interaction */
virtual bool ParameterInteraction() const = 0;
/** Add wallets that should be opened to list of chain clients. */
- virtual void Construct(NodeContext &node) const = 0;
+ virtual void Construct(node::NodeContext &node) const = 0;
virtual ~WalletInitInterface() {}
};
diff --git a/src/zmq/zmqpublishnotifier.cpp b/src/zmq/zmqpublishnotifier.cpp
--- a/src/zmq/zmqpublishnotifier.cpp
+++ b/src/zmq/zmqpublishnotifier.cpp
@@ -23,6 +23,8 @@
#include <string>
#include <utility>
+using node::ReadBlockFromDisk;
+
static std::multimap<std::string, CZMQAbstractPublishNotifier *>
mapPublishNotifiers;

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 26, 12:06 (2 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5571586
Default Alt Text
D12763.id36990.diff (39 KB)

Event Timeline