From faa3d38ec6f2999740486c6c66cd062e74c769fb Mon Sep 17 00:00:00 2001 From: MacroFake Date: Thu, 26 May 2022 17:06:07 +0200 Subject: refactor: Pass reference to LookUpStats --- src/index/coinstatsindex.cpp | 7 ++++--- src/index/coinstatsindex.h | 11 +++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src/index') diff --git a/src/index/coinstatsindex.cpp b/src/index/coinstatsindex.cpp index b9029e946a..99a1310c9e 100644 --- a/src/index/coinstatsindex.cpp +++ b/src/index/coinstatsindex.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -322,13 +323,13 @@ static bool LookUpOne(const CDBWrapper& db, const interfaces::BlockKey& block, D return db.Read(DBHashKey(block.hash), result); } -std::optional CoinStatsIndex::LookUpStats(const CBlockIndex* block_index) const +std::optional CoinStatsIndex::LookUpStats(const CBlockIndex& block_index) const { - CCoinsStats stats{Assert(block_index)->nHeight, block_index->GetBlockHash()}; + CCoinsStats stats{block_index.nHeight, block_index.GetBlockHash()}; stats.index_used = true; DBVal entry; - if (!LookUpOne(*m_db, {block_index->GetBlockHash(), block_index->nHeight}, entry)) { + if (!LookUpOne(*m_db, {block_index.GetBlockHash(), block_index.nHeight}, entry)) { return std::nullopt; } diff --git a/src/index/coinstatsindex.h b/src/index/coinstatsindex.h index c4af223388..7375a85750 100644 --- a/src/index/coinstatsindex.h +++ b/src/index/coinstatsindex.h @@ -5,11 +5,14 @@ #ifndef BITCOIN_INDEX_COINSTATSINDEX_H #define BITCOIN_INDEX_COINSTATSINDEX_H -#include #include -#include #include -#include + +class CBlockIndex; +class CDBBatch; +namespace kernel { +struct CCoinsStats; +} /** * CoinStatsIndex maintains statistics on the UTXO set. @@ -56,7 +59,7 @@ public: explicit CoinStatsIndex(std::unique_ptr chain, size_t n_cache_size, bool f_memory = false, bool f_wipe = false); // Look up stats for a specific block using CBlockIndex - std::optional LookUpStats(const CBlockIndex* block_index) const; + std::optional LookUpStats(const CBlockIndex& block_index) const; }; /// The global UTXO set hash object. -- cgit v1.2.3