mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-20 14:05:23 +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 <validation.h>
|
||||
|
||||
using node::CCoinsStats;
|
||||
using node::GetBogoSize;
|
||||
using kernel::CCoinsStats;
|
||||
using kernel::GetBogoSize;
|
||||
using node::ReadBlockFromDisk;
|
||||
using node::TxOutSer;
|
||||
using kernel::TxOutSer;
|
||||
using node::UndoReadFromDisk;
|
||||
|
||||
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);
|
||||
|
||||
// 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.
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include <map>
|
||||
|
||||
namespace node {
|
||||
namespace kernel {
|
||||
|
||||
CCoinsStats::CCoinsStats(int block_height, const uint256& block_hash)
|
||||
: nHeight(block_height),
|
||||
|
@ -135,7 +135,7 @@ static bool ComputeUTXOStats(CCoinsView* view, CCoinsStats& stats, T hash_obj, c
|
|||
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()));
|
||||
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) {}
|
||||
|
||||
} // namespace node
|
||||
} // namespace kernel
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace node {
|
|||
class BlockManager;
|
||||
} // namespace node
|
||||
|
||||
namespace node {
|
||||
namespace kernel {
|
||||
enum class CoinStatsHashType {
|
||||
HASH_SERIALIZED,
|
||||
MUHASH,
|
||||
|
@ -73,6 +73,6 @@ uint64_t GetBogoSize(const CScript& script_pub_key);
|
|||
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 = {});
|
||||
} // namespace node
|
||||
} // namespace kernel
|
||||
|
||||
#endif // BITCOIN_KERNEL_COINSTATS_H
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
#include <validation.h>
|
||||
|
||||
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
|
||||
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) {
|
||||
return g_coin_stats_index->LookUpStats(pindex);
|
||||
} else {
|
||||
|
@ -29,6 +29,6 @@ std::optional<CCoinsStats> GetUTXOStats(CCoinsView* view, BlockManager& blockman
|
|||
// best block.
|
||||
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
|
||||
|
|
|
@ -28,8 +28,8 @@ namespace node {
|
|||
*
|
||||
* @param[in] index_requested Signals if the coinstatsindex should be used (when available).
|
||||
*/
|
||||
std::optional<CCoinsStats> GetUTXOStats(CCoinsView* view, node::BlockManager& blockman,
|
||||
CoinStatsHashType hash_type,
|
||||
std::optional<kernel::CCoinsStats> GetUTXOStats(CCoinsView* view, node::BlockManager& blockman,
|
||||
kernel::CoinStatsHashType hash_type,
|
||||
const std::function<void()>& interruption_point = {},
|
||||
const CBlockIndex* pindex = nullptr,
|
||||
bool index_requested = true);
|
||||
|
|
|
@ -52,8 +52,8 @@
|
|||
#include <mutex>
|
||||
|
||||
using node::BlockManager;
|
||||
using node::CCoinsStats;
|
||||
using node::CoinStatsHashType;
|
||||
using kernel::CCoinsStats;
|
||||
using kernel::CoinStatsHashType;
|
||||
using node::GetUTXOStats;
|
||||
using node::NodeContext;
|
||||
using node::ReadBlockFromDisk;
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
|
||||
#include <chrono>
|
||||
|
||||
using node::CCoinsStats;
|
||||
using node::CoinStatsHashType;
|
||||
using kernel::CCoinsStats;
|
||||
using kernel::CoinStatsHashType;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(coinstatsindex_tests)
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@ using node::BlockManager;
|
|||
using node::BlockMap;
|
||||
using node::CBlockIndexHeightOnlyComparator;
|
||||
using node::CBlockIndexWorkComparator;
|
||||
using node::CCoinsStats;
|
||||
using node::CoinStatsHashType;
|
||||
using kernel::CCoinsStats;
|
||||
using kernel::CoinStatsHashType;
|
||||
using node::fImporting;
|
||||
using node::fPruneMode;
|
||||
using node::fReindex;
|
||||
|
|
Loading…
Add table
Reference in a new issue