Skip to content

Commit f329a92

Browse files
committed
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-
1 parent 0e54456 commit f329a92

File tree

9 files changed

+20
-20
lines changed

9 files changed

+20
-20
lines changed

src/index/coinstatsindex.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
#include <undo.h>
1313
#include <validation.h>
1414

15-
using node::CCoinsStats;
16-
using node::GetBogoSize;
15+
using kernel::CCoinsStats;
16+
using kernel::GetBogoSize;
1717
using node::ReadBlockFromDisk;
18-
using node::TxOutSer;
18+
using kernel::TxOutSer;
1919
using node::UndoReadFromDisk;
2020

2121
static constexpr uint8_t DB_BLOCK_HASH{'s'};

src/index/coinstatsindex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class CoinStatsIndex final : public BaseIndex
5656
explicit CoinStatsIndex(size_t n_cache_size, bool f_memory = false, bool f_wipe = false);
5757

5858
// Look up stats for a specific block using CBlockIndex
59-
std::optional<node::CCoinsStats> LookUpStats(const CBlockIndex* block_index) const;
59+
std::optional<kernel::CCoinsStats> LookUpStats(const CBlockIndex* block_index) const;
6060
};
6161

6262
/// The global UTXO set hash object.

src/kernel/coinstats.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include <map>
1717

18-
namespace node {
18+
namespace kernel {
1919

2020
CCoinsStats::CCoinsStats(int block_height, const uint256& block_hash)
2121
: nHeight(block_height),
@@ -135,7 +135,7 @@ static bool ComputeUTXOStats(CCoinsView* view, CCoinsStats& stats, T hash_obj, c
135135
return true;
136136
}
137137

138-
std::optional<CCoinsStats> ComputeUTXOStats(CoinStatsHashType hash_type, CCoinsView* view, BlockManager& blockman, const std::function<void()>& interruption_point)
138+
std::optional<CCoinsStats> ComputeUTXOStats(CoinStatsHashType hash_type, CCoinsView* view, node::BlockManager& blockman, const std::function<void()>& interruption_point)
139139
{
140140
CBlockIndex* pindex = WITH_LOCK(::cs_main, return blockman.LookupBlockIndex(view->GetBestBlock()));
141141
CCoinsStats stats{Assert(pindex)->nHeight, pindex->GetBlockHash()};
@@ -184,4 +184,4 @@ static void FinalizeHash(MuHash3072& muhash, CCoinsStats& stats)
184184
}
185185
static void FinalizeHash(std::nullptr_t, CCoinsStats& stats) {}
186186

187-
} // namespace node
187+
} // namespace kernel

src/kernel/coinstats.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace node {
1919
class BlockManager;
2020
} // namespace node
2121

22-
namespace node {
22+
namespace kernel {
2323
enum class CoinStatsHashType {
2424
HASH_SERIALIZED,
2525
MUHASH,
@@ -73,6 +73,6 @@ uint64_t GetBogoSize(const CScript& script_pub_key);
7373
CDataStream TxOutSer(const COutPoint& outpoint, const Coin& coin);
7474

7575
std::optional<CCoinsStats> ComputeUTXOStats(CoinStatsHashType hash_type, CCoinsView* view, node::BlockManager& blockman, const std::function<void()>& interruption_point = {});
76-
} // namespace node
76+
} // namespace kernel
7777

7878
#endif // BITCOIN_KERNEL_COINSTATS_H

src/node/coinstats.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
#include <validation.h>
1212

1313
namespace node {
14-
std::optional<CCoinsStats> GetUTXOStats(CCoinsView* view, BlockManager& blockman, CoinStatsHashType hash_type, const std::function<void()>& interruption_point, const CBlockIndex* pindex, bool index_requested)
14+
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)
1515
{
1616
// Use CoinStatsIndex if it is requested and available and a hash_type of Muhash or None was requested
17-
if ((hash_type == CoinStatsHashType::MUHASH || hash_type == CoinStatsHashType::NONE) && g_coin_stats_index && index_requested) {
17+
if ((hash_type == kernel::CoinStatsHashType::MUHASH || hash_type == kernel::CoinStatsHashType::NONE) && g_coin_stats_index && index_requested) {
1818
if (pindex) {
1919
return g_coin_stats_index->LookUpStats(pindex);
2020
} else {
@@ -29,6 +29,6 @@ std::optional<CCoinsStats> GetUTXOStats(CCoinsView* view, BlockManager& blockman
2929
// best block.
3030
assert(!pindex || pindex->GetBlockHash() == view->GetBestBlock());
3131

32-
return ComputeUTXOStats(hash_type, view, blockman, interruption_point);
32+
return kernel::ComputeUTXOStats(hash_type, view, blockman, interruption_point);
3333
}
3434
} // namespace node

src/node/coinstats.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ namespace node {
2828
*
2929
* @param[in] index_requested Signals if the coinstatsindex should be used (when available).
3030
*/
31-
std::optional<CCoinsStats> GetUTXOStats(CCoinsView* view, node::BlockManager& blockman,
32-
CoinStatsHashType hash_type,
31+
std::optional<kernel::CCoinsStats> GetUTXOStats(CCoinsView* view, node::BlockManager& blockman,
32+
kernel::CoinStatsHashType hash_type,
3333
const std::function<void()>& interruption_point = {},
3434
const CBlockIndex* pindex = nullptr,
3535
bool index_requested = true);

src/rpc/blockchain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
#include <mutex>
5353

5454
using node::BlockManager;
55-
using node::CCoinsStats;
56-
using node::CoinStatsHashType;
55+
using kernel::CCoinsStats;
56+
using kernel::CoinStatsHashType;
5757
using node::GetUTXOStats;
5858
using node::NodeContext;
5959
using node::ReadBlockFromDisk;

src/test/coinstatsindex_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
#include <chrono>
1515

16-
using node::CCoinsStats;
17-
using node::CoinStatsHashType;
16+
using kernel::CCoinsStats;
17+
using kernel::CoinStatsHashType;
1818

1919
BOOST_AUTO_TEST_SUITE(coinstatsindex_tests)
2020

src/validation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ using node::BlockManager;
6363
using node::BlockMap;
6464
using node::CBlockIndexHeightOnlyComparator;
6565
using node::CBlockIndexWorkComparator;
66-
using node::CCoinsStats;
67-
using node::CoinStatsHashType;
66+
using kernel::CCoinsStats;
67+
using kernel::CoinStatsHashType;
6868
using node::fImporting;
6969
using node::fPruneMode;
7070
using node::fReindex;

0 commit comments

Comments
 (0)