diff options
author | Carl Dong <contact@carldong.me> | 2022-02-16 17:58:41 -0500 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2022-05-23 14:53:35 -0400 |
commit | f329a9298c06ffe74b9e9fbc07bfe6d282fef9cb (patch) | |
tree | 441ef3ea0f23e9da9b8092826c7d09a18edc6850 /src | |
parent | 0e54456f0498e52131f8ae0c76b4dfe25f45b076 (diff) | |
download | bitcoin-f329a9298c06ffe74b9e9fbc07bfe6d282fef9cb.tar.xz |
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-
Diffstat (limited to 'src')
-rw-r--r-- | src/index/coinstatsindex.cpp | 6 | ||||
-rw-r--r-- | src/index/coinstatsindex.h | 2 | ||||
-rw-r--r-- | src/kernel/coinstats.cpp | 6 | ||||
-rw-r--r-- | src/kernel/coinstats.h | 4 | ||||
-rw-r--r-- | src/node/coinstats.cpp | 6 | ||||
-rw-r--r-- | src/node/coinstats.h | 4 | ||||
-rw-r--r-- | src/rpc/blockchain.cpp | 4 | ||||
-rw-r--r-- | src/test/coinstatsindex_tests.cpp | 4 | ||||
-rw-r--r-- | src/validation.cpp | 4 |
9 files changed, 20 insertions, 20 deletions
diff --git a/src/index/coinstatsindex.cpp b/src/index/coinstatsindex.cpp index c4bc47e538..666eb4fdb0 100644 --- a/src/index/coinstatsindex.cpp +++ b/src/index/coinstatsindex.cpp @@ -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'}; diff --git a/src/index/coinstatsindex.h b/src/index/coinstatsindex.h index 315f1fa14a..cae052d913 100644 --- a/src/index/coinstatsindex.h +++ b/src/index/coinstatsindex.h @@ -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. diff --git a/src/kernel/coinstats.cpp b/src/kernel/coinstats.cpp index 49db98d663..f380871627 100644 --- a/src/kernel/coinstats.cpp +++ b/src/kernel/coinstats.cpp @@ -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 diff --git a/src/kernel/coinstats.h b/src/kernel/coinstats.h index d470ea715a..a15957233f 100644 --- a/src/kernel/coinstats.h +++ b/src/kernel/coinstats.h @@ -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 diff --git a/src/node/coinstats.cpp b/src/node/coinstats.cpp index 12c8e7b0da..784d33d698 100644 --- a/src/node/coinstats.cpp +++ b/src/node/coinstats.cpp @@ -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 diff --git a/src/node/coinstats.h b/src/node/coinstats.h index fbd5fd4067..b1d1384bb3 100644 --- a/src/node/coinstats.h +++ b/src/node/coinstats.h @@ -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); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 97983cea5a..8789d76f3c 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -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; diff --git a/src/test/coinstatsindex_tests.cpp b/src/test/coinstatsindex_tests.cpp index c3b6870cbd..50eb479035 100644 --- a/src/test/coinstatsindex_tests.cpp +++ b/src/test/coinstatsindex_tests.cpp @@ -13,8 +13,8 @@ #include <chrono> -using node::CCoinsStats; -using node::CoinStatsHashType; +using kernel::CCoinsStats; +using kernel::CoinStatsHashType; BOOST_AUTO_TEST_SUITE(coinstatsindex_tests) diff --git a/src/validation.cpp b/src/validation.cpp index 40c2618db9..afaea9bb78 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -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; |