mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-16 10:30:41 +01:00
Add src/node/* code to node:: namespace
This commit is contained in:
@@ -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;
|
||||
@@ -472,12 +473,14 @@ void CleanupBlockRevFiles()
|
||||
remove(item.second);
|
||||
}
|
||||
}
|
||||
} // namespace node
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
namespace node {
|
||||
CBlockFileInfo* BlockManager::GetBlockFileInfo(size_t n)
|
||||
{
|
||||
LOCK(cs_LastBlockFile);
|
||||
@@ -939,3 +942,4 @@ void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFile
|
||||
} // End scope of CImportingNow
|
||||
chainman.ActiveChainstate().LoadMempool(args);
|
||||
}
|
||||
} // namespace node
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace Consensus {
|
||||
struct Params;
|
||||
}
|
||||
|
||||
namespace node {
|
||||
static constexpr bool DEFAULT_STOPAFTERBLOCKIMPORT{false};
|
||||
|
||||
/** 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
|
||||
bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex);
|
||||
|
||||
void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFiles, const ArgsManager& args);
|
||||
} // namespace node
|
||||
|
||||
#endif // BITCOIN_NODE_BLOCKSTORAGE_H
|
||||
|
||||
@@ -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", nDefaultDbCache) << 20);
|
||||
@@ -30,3 +31,4 @@ CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes)
|
||||
sizes.coins = nTotalCache; // the rest goes to in-memory cache
|
||||
return sizes;
|
||||
}
|
||||
} // namespace node
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
class ArgsManager;
|
||||
|
||||
namespace node {
|
||||
struct CacheSizes {
|
||||
int64_t block_tree_db;
|
||||
int64_t coins_db;
|
||||
@@ -18,5 +19,6 @@ struct CacheSizes {
|
||||
int64_t filter_index;
|
||||
};
|
||||
CacheSizes CalculateCacheSizes(const ArgsManager& args, size_t n_indexes = 0);
|
||||
} // namespace node
|
||||
|
||||
#endif // BITCOIN_NODE_CACHES_H
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <node/blockstorage.h>
|
||||
#include <validation.h>
|
||||
|
||||
namespace node {
|
||||
std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
||||
ChainstateManager& chainman,
|
||||
CTxMemPool* mempool,
|
||||
@@ -156,3 +157,4 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
} // namespace node
|
||||
|
||||
@@ -10,11 +10,12 @@
|
||||
#include <optional>
|
||||
|
||||
class ChainstateManager;
|
||||
namespace Consensus {
|
||||
struct Params;
|
||||
}
|
||||
class CTxMemPool;
|
||||
namespace Consensus {
|
||||
struct Params;
|
||||
} // namespace Consensus
|
||||
|
||||
namespace node {
|
||||
enum class ChainstateLoadingError {
|
||||
ERROR_LOADING_BLOCK_DB,
|
||||
ERROR_BAD_GENESIS_BLOCK,
|
||||
@@ -81,5 +82,6 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage
|
||||
unsigned int check_blocks,
|
||||
unsigned int check_level,
|
||||
std::function<int64_t()> get_unix_time_seconds);
|
||||
} // namespace node
|
||||
|
||||
#endif // BITCOIN_NODE_CHAINSTATE_H
|
||||
|
||||
@@ -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);
|
||||
@@ -22,3 +23,4 @@ void FindCoins(const NodeContext& node, std::map<COutPoint, Coin>& coins)
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace node
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
class COutPoint;
|
||||
class Coin;
|
||||
|
||||
namespace node {
|
||||
struct NodeContext;
|
||||
|
||||
/**
|
||||
@@ -19,6 +21,7 @@ struct NodeContext;
|
||||
* @param[in] node The node context to use for lookup
|
||||
* @param[in,out] coins map to fill
|
||||
*/
|
||||
void FindCoins(const NodeContext& node, std::map<COutPoint, Coin>& coins);
|
||||
void FindCoins(const node::NodeContext& node, std::map<COutPoint, Coin>& coins);
|
||||
} // namespace node
|
||||
|
||||
#endif // BITCOIN_NODE_COIN_H
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace node {
|
||||
// Database-independent metric indicating the UTXO set size
|
||||
uint64_t GetBogoSize(const CScript& script_pub_key)
|
||||
{
|
||||
@@ -181,3 +182,4 @@ static void FinalizeHash(MuHash3072& muhash, CCoinsStats& stats)
|
||||
stats.hashSerialized = out;
|
||||
}
|
||||
static void FinalizeHash(std::nullptr_t, CCoinsStats& stats) {}
|
||||
} // namespace node
|
||||
|
||||
@@ -15,9 +15,12 @@
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
|
||||
class BlockManager;
|
||||
class CCoinsView;
|
||||
namespace node {
|
||||
class BlockManager;
|
||||
} // namespace node
|
||||
|
||||
namespace node {
|
||||
enum class CoinStatsHashType {
|
||||
HASH_SERIALIZED,
|
||||
MUHASH,
|
||||
@@ -71,10 +74,11 @@ struct CCoinsStats {
|
||||
};
|
||||
|
||||
//! Calculate statistics about the unspent transaction output set
|
||||
bool GetUTXOStats(CCoinsView* view, BlockManager& blockman, CCoinsStats& stats, const std::function<void()>& interruption_point = {}, const CBlockIndex* pindex = nullptr);
|
||||
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
|
||||
|
||||
@@ -14,5 +14,7 @@
|
||||
#include <txmempool.h>
|
||||
#include <validation.h>
|
||||
|
||||
namespace node {
|
||||
NodeContext::NodeContext() {}
|
||||
NodeContext::~NodeContext() {}
|
||||
} // namespace node
|
||||
|
||||
@@ -26,6 +26,7 @@ class Init;
|
||||
class WalletLoader;
|
||||
} // namespace interfaces
|
||||
|
||||
namespace node {
|
||||
//! NodeContext struct containing references to chain state and connection
|
||||
//! state.
|
||||
//!
|
||||
@@ -62,5 +63,6 @@ struct NodeContext {
|
||||
NodeContext();
|
||||
~NodeContext();
|
||||
};
|
||||
} // namespace node
|
||||
|
||||
#endif // BITCOIN_NODE_CONTEXT_H
|
||||
|
||||
@@ -249,8 +249,8 @@ public:
|
||||
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) {
|
||||
@@ -649,9 +649,9 @@ public:
|
||||
bool havePruned() override
|
||||
{
|
||||
LOCK(cs_main);
|
||||
return ::fHavePruned;
|
||||
return node::fHavePruned;
|
||||
}
|
||||
bool isReadyToBroadcast() override { return !::fImporting && !::fReindex && !isInitialBlockDownload(); }
|
||||
bool isReadyToBroadcast() override { return !node::fImporting && !node::fReindex && !isInitialBlockDownload(); }
|
||||
bool isInitialBlockDownload() override {
|
||||
return chainman().ActiveChainstate().IsInitialBlockDownload();
|
||||
}
|
||||
@@ -729,6 +729,6 @@ public:
|
||||
} // namespace node
|
||||
|
||||
namespace interfaces {
|
||||
std::unique_ptr<Node> MakeNode(NodeContext& context) { return std::make_unique<node::NodeImpl>(context); }
|
||||
std::unique_ptr<Chain> MakeChain(NodeContext& context) { return std::make_unique<node::ChainImpl>(context); }
|
||||
std::unique_ptr<Node> MakeNode(node::NodeContext& context) { return std::make_unique<node::NodeImpl>(context); }
|
||||
std::unique_ptr<Chain> MakeChain(node::NodeContext& context) { return std::make_unique<node::ChainImpl>(context); }
|
||||
} // namespace interfaces
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
namespace node {
|
||||
int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev)
|
||||
{
|
||||
int64_t nOldTime = pblock->nTime;
|
||||
@@ -464,3 +465,4 @@ void IncrementExtraNonce(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned
|
||||
pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase));
|
||||
pblock->hashMerkleRoot = BlockMerkleRoot(*pblock);
|
||||
}
|
||||
} // namespace node
|
||||
|
||||
@@ -23,6 +23,7 @@ class CScript;
|
||||
|
||||
namespace Consensus { struct Params; };
|
||||
|
||||
namespace node {
|
||||
static const bool DEFAULT_PRINTPRIORITY = false;
|
||||
|
||||
struct CBlockTemplate
|
||||
@@ -206,5 +207,6 @@ int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParam
|
||||
|
||||
/** Update an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed */
|
||||
void RegenerateCommitments(CBlock& block, ChainstateManager& chainman);
|
||||
} // namespace node
|
||||
|
||||
#endif // BITCOIN_NODE_MINER_H
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace node {
|
||||
namespace {
|
||||
|
||||
static constexpr uint32_t BITS = 32;
|
||||
@@ -75,3 +76,4 @@ Minisketch MakeMinisketch32FP(size_t max_elements, uint32_t fpbits)
|
||||
{
|
||||
return Minisketch::CreateFP(BITS, Minisketch32Implementation(), max_elements, fpbits);
|
||||
}
|
||||
} // namespace node
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace node {
|
||||
/** Wrapper around Minisketch::Minisketch(32, implementation, capacity). */
|
||||
Minisketch MakeMinisketch32(size_t capacity);
|
||||
/** Wrapper around Minisketch::CreateFP. */
|
||||
Minisketch MakeMinisketch32FP(size_t max_elements, uint32_t fpbits);
|
||||
} // namespace node
|
||||
|
||||
#endif // BITCOIN_NODE_MINISKETCHWRAPPER_H
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <numeric>
|
||||
|
||||
namespace node {
|
||||
PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx)
|
||||
{
|
||||
// Go through each input and build status
|
||||
@@ -147,3 +148,4 @@ PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx)
|
||||
|
||||
return result;
|
||||
}
|
||||
} // namespace node
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace node {
|
||||
/**
|
||||
* Holds an analysis of one input from a PSBT
|
||||
*/
|
||||
@@ -52,5 +53,6 @@ struct PSBTAnalysis {
|
||||
* @return A PSBTAnalysis with information about the provided PSBT.
|
||||
*/
|
||||
PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx);
|
||||
} // namespace node
|
||||
|
||||
#endif // BITCOIN_NODE_PSBT_H
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <future>
|
||||
|
||||
namespace node {
|
||||
static TransactionError HandleATMPError(const TxValidationState& state, std::string& err_string_out)
|
||||
{
|
||||
err_string_out = state.ToString();
|
||||
@@ -153,3 +154,4 @@ CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMe
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace node
|
||||
|
||||
@@ -12,11 +12,13 @@
|
||||
|
||||
class CBlockIndex;
|
||||
class CTxMemPool;
|
||||
struct NodeContext;
|
||||
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.
|
||||
* By default, a transaction with a fee rate higher than this will be rejected
|
||||
@@ -57,5 +59,6 @@ static const CFeeRate DEFAULT_MAX_RAW_TX_FEE_RATE{COIN / 10};
|
||||
* @returns The tx if found, otherwise nullptr
|
||||
*/
|
||||
CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const uint256& hash, const Consensus::Params& consensusParams, uint256& hashBlock);
|
||||
} // namespace node
|
||||
|
||||
#endif // BITCOIN_NODE_TRANSACTION_H
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <uint256.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
|
||||
@@ -32,5 +33,6 @@ public:
|
||||
|
||||
SERIALIZE_METHODS(SnapshotMetadata, obj) { READWRITE(obj.m_base_blockhash, obj.m_coins_count); }
|
||||
};
|
||||
} // namespace node
|
||||
|
||||
#endif // BITCOIN_NODE_UTXO_SNAPSHOT_H
|
||||
|
||||
Reference in New Issue
Block a user