mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
scripted-diff: Move src/kernel/coinstats to kernel::
Introduces a new kernel:: namespace and move all of src/kernel/coinstats under it. In the verify script, lines like: line="$(grep -n 'namespace node {' -- src/kernel/coinstats.h | tail -n1 | cut -d: -f1)" sed -i -e "${line}s@namespace node {@namespace kernel {@" -- src/kernel/coinstats.h Are intended to replace only the last instance of "namespace node" with "namespace kernel", this is to avoid replacing forward declarations of things inside the node:: namespace. -BEGIN VERIFY SCRIPT- sed -E -i 's@namespace node@namespace kernel@g' -- src/kernel/coinstats.cpp line="$(grep -n 'namespace node {' -- src/kernel/coinstats.h | tail -n1 | cut -d: -f1)" sed -i -e "${line}s@namespace node {@namespace kernel {@" -- src/kernel/coinstats.h line="$(grep -n '// namespace node' -- src/kernel/coinstats.h | tail -n1 | cut -d: -f1)" sed -i -e "${line}s@// namespace node@// namespace kernel@" -- src/kernel/coinstats.h things='(CCoinsStats|CoinStatsHashType|GetBogoSize|TxOutSer|ComputeUTXOStats)' git grep -lE 'node::'"$things" | xargs sed -E -i 's@node::'"$things"'@kernel::\1@g' sed -E -i 's@'"$things"'@kernel::\1@g' -- src/node/coinstats.cpp src/node/coinstats.h sed -E -i 's@BlockManager@node::\0@g' -- src/kernel/coinstats.cpp -END VERIFY SCRIPT-
This commit is contained in:
parent
0e54456f04
commit
f329a9298c
9 changed files with 20 additions and 20 deletions
|
@ -12,10 +12,10 @@
|
||||||
#include <undo.h>
|
#include <undo.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
using node::CCoinsStats;
|
using kernel::CCoinsStats;
|
||||||
using node::GetBogoSize;
|
using kernel::GetBogoSize;
|
||||||
using node::ReadBlockFromDisk;
|
using node::ReadBlockFromDisk;
|
||||||
using node::TxOutSer;
|
using kernel::TxOutSer;
|
||||||
using node::UndoReadFromDisk;
|
using node::UndoReadFromDisk;
|
||||||
|
|
||||||
static constexpr uint8_t DB_BLOCK_HASH{'s'};
|
static constexpr uint8_t DB_BLOCK_HASH{'s'};
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
explicit CoinStatsIndex(size_t n_cache_size, bool f_memory = false, bool f_wipe = false);
|
explicit CoinStatsIndex(size_t n_cache_size, bool f_memory = false, bool f_wipe = false);
|
||||||
|
|
||||||
// Look up stats for a specific block using CBlockIndex
|
// Look up stats for a specific block using CBlockIndex
|
||||||
std::optional<node::CCoinsStats> LookUpStats(const CBlockIndex* block_index) const;
|
std::optional<kernel::CCoinsStats> LookUpStats(const CBlockIndex* block_index) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The global UTXO set hash object.
|
/// The global UTXO set hash object.
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace node {
|
namespace kernel {
|
||||||
|
|
||||||
CCoinsStats::CCoinsStats(int block_height, const uint256& block_hash)
|
CCoinsStats::CCoinsStats(int block_height, const uint256& block_hash)
|
||||||
: nHeight(block_height),
|
: nHeight(block_height),
|
||||||
|
@ -135,7 +135,7 @@ static bool ComputeUTXOStats(CCoinsView* view, CCoinsStats& stats, T hash_obj, c
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<CCoinsStats> ComputeUTXOStats(CoinStatsHashType hash_type, CCoinsView* view, BlockManager& blockman, const std::function<void()>& interruption_point)
|
std::optional<CCoinsStats> ComputeUTXOStats(CoinStatsHashType hash_type, CCoinsView* view, node::BlockManager& blockman, const std::function<void()>& interruption_point)
|
||||||
{
|
{
|
||||||
CBlockIndex* pindex = WITH_LOCK(::cs_main, return blockman.LookupBlockIndex(view->GetBestBlock()));
|
CBlockIndex* pindex = WITH_LOCK(::cs_main, return blockman.LookupBlockIndex(view->GetBestBlock()));
|
||||||
CCoinsStats stats{Assert(pindex)->nHeight, pindex->GetBlockHash()};
|
CCoinsStats stats{Assert(pindex)->nHeight, pindex->GetBlockHash()};
|
||||||
|
@ -184,4 +184,4 @@ static void FinalizeHash(MuHash3072& muhash, CCoinsStats& stats)
|
||||||
}
|
}
|
||||||
static void FinalizeHash(std::nullptr_t, CCoinsStats& stats) {}
|
static void FinalizeHash(std::nullptr_t, CCoinsStats& stats) {}
|
||||||
|
|
||||||
} // namespace node
|
} // namespace kernel
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace node {
|
||||||
class BlockManager;
|
class BlockManager;
|
||||||
} // namespace node
|
} // namespace node
|
||||||
|
|
||||||
namespace node {
|
namespace kernel {
|
||||||
enum class CoinStatsHashType {
|
enum class CoinStatsHashType {
|
||||||
HASH_SERIALIZED,
|
HASH_SERIALIZED,
|
||||||
MUHASH,
|
MUHASH,
|
||||||
|
@ -73,6 +73,6 @@ uint64_t GetBogoSize(const CScript& script_pub_key);
|
||||||
CDataStream TxOutSer(const COutPoint& outpoint, const Coin& coin);
|
CDataStream TxOutSer(const COutPoint& outpoint, const Coin& coin);
|
||||||
|
|
||||||
std::optional<CCoinsStats> ComputeUTXOStats(CoinStatsHashType hash_type, CCoinsView* view, node::BlockManager& blockman, const std::function<void()>& interruption_point = {});
|
std::optional<CCoinsStats> ComputeUTXOStats(CoinStatsHashType hash_type, CCoinsView* view, node::BlockManager& blockman, const std::function<void()>& interruption_point = {});
|
||||||
} // namespace node
|
} // namespace kernel
|
||||||
|
|
||||||
#endif // BITCOIN_KERNEL_COINSTATS_H
|
#endif // BITCOIN_KERNEL_COINSTATS_H
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
namespace node {
|
namespace node {
|
||||||
std::optional<CCoinsStats> GetUTXOStats(CCoinsView* view, BlockManager& blockman, CoinStatsHashType hash_type, const std::function<void()>& interruption_point, const CBlockIndex* pindex, bool index_requested)
|
std::optional<kernel::CCoinsStats> GetUTXOStats(CCoinsView* view, BlockManager& blockman, kernel::CoinStatsHashType hash_type, const std::function<void()>& interruption_point, const CBlockIndex* pindex, bool index_requested)
|
||||||
{
|
{
|
||||||
// Use CoinStatsIndex if it is requested and available and a hash_type of Muhash or None was requested
|
// Use CoinStatsIndex if it is requested and available and a hash_type of Muhash or None was requested
|
||||||
if ((hash_type == CoinStatsHashType::MUHASH || hash_type == CoinStatsHashType::NONE) && g_coin_stats_index && index_requested) {
|
if ((hash_type == kernel::CoinStatsHashType::MUHASH || hash_type == kernel::CoinStatsHashType::NONE) && g_coin_stats_index && index_requested) {
|
||||||
if (pindex) {
|
if (pindex) {
|
||||||
return g_coin_stats_index->LookUpStats(pindex);
|
return g_coin_stats_index->LookUpStats(pindex);
|
||||||
} else {
|
} else {
|
||||||
|
@ -29,6 +29,6 @@ std::optional<CCoinsStats> GetUTXOStats(CCoinsView* view, BlockManager& blockman
|
||||||
// best block.
|
// best block.
|
||||||
assert(!pindex || pindex->GetBlockHash() == view->GetBestBlock());
|
assert(!pindex || pindex->GetBlockHash() == view->GetBestBlock());
|
||||||
|
|
||||||
return ComputeUTXOStats(hash_type, view, blockman, interruption_point);
|
return kernel::ComputeUTXOStats(hash_type, view, blockman, interruption_point);
|
||||||
}
|
}
|
||||||
} // namespace node
|
} // namespace node
|
||||||
|
|
|
@ -28,8 +28,8 @@ namespace node {
|
||||||
*
|
*
|
||||||
* @param[in] index_requested Signals if the coinstatsindex should be used (when available).
|
* @param[in] index_requested Signals if the coinstatsindex should be used (when available).
|
||||||
*/
|
*/
|
||||||
std::optional<CCoinsStats> GetUTXOStats(CCoinsView* view, node::BlockManager& blockman,
|
std::optional<kernel::CCoinsStats> GetUTXOStats(CCoinsView* view, node::BlockManager& blockman,
|
||||||
CoinStatsHashType hash_type,
|
kernel::CoinStatsHashType hash_type,
|
||||||
const std::function<void()>& interruption_point = {},
|
const std::function<void()>& interruption_point = {},
|
||||||
const CBlockIndex* pindex = nullptr,
|
const CBlockIndex* pindex = nullptr,
|
||||||
bool index_requested = true);
|
bool index_requested = true);
|
||||||
|
|
|
@ -52,8 +52,8 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
using node::BlockManager;
|
using node::BlockManager;
|
||||||
using node::CCoinsStats;
|
using kernel::CCoinsStats;
|
||||||
using node::CoinStatsHashType;
|
using kernel::CoinStatsHashType;
|
||||||
using node::GetUTXOStats;
|
using node::GetUTXOStats;
|
||||||
using node::NodeContext;
|
using node::NodeContext;
|
||||||
using node::ReadBlockFromDisk;
|
using node::ReadBlockFromDisk;
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
using node::CCoinsStats;
|
using kernel::CCoinsStats;
|
||||||
using node::CoinStatsHashType;
|
using kernel::CoinStatsHashType;
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(coinstatsindex_tests)
|
BOOST_AUTO_TEST_SUITE(coinstatsindex_tests)
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,8 @@ using node::BlockManager;
|
||||||
using node::BlockMap;
|
using node::BlockMap;
|
||||||
using node::CBlockIndexHeightOnlyComparator;
|
using node::CBlockIndexHeightOnlyComparator;
|
||||||
using node::CBlockIndexWorkComparator;
|
using node::CBlockIndexWorkComparator;
|
||||||
using node::CCoinsStats;
|
using kernel::CCoinsStats;
|
||||||
using node::CoinStatsHashType;
|
using kernel::CoinStatsHashType;
|
||||||
using node::fImporting;
|
using node::fImporting;
|
||||||
using node::fPruneMode;
|
using node::fPruneMode;
|
||||||
using node::fReindex;
|
using node::fReindex;
|
||||||
|
|
Loading…
Add table
Reference in a new issue