aboutsummaryrefslogtreecommitdiff
path: root/src/index
diff options
context:
space:
mode:
authorRyan Ofsky <ryan@ofsky.org>2022-01-17 17:32:19 -0500
committerRyan Ofsky <ryan@ofsky.org>2022-07-18 13:39:55 -0500
commitaddb4f2af183a25ce4a6b6485b5b49575a2ba31b (patch)
treeb6309ded5636d485af52a696e016e8dc235f07b3 /src/index
parent33b4d48cfcdf145f49cb2283ac3e2936a4e23fff (diff)
downloadbitcoin-addb4f2af183a25ce4a6b6485b5b49575a2ba31b.tar.xz
indexes, refactor: Remove CBlockIndex* uses in coinstatsindex LookUpOne function
This commit does not change behavior in any way.
Diffstat (limited to 'src/index')
-rw-r--r--src/index/coinstatsindex.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/index/coinstatsindex.cpp b/src/index/coinstatsindex.cpp
index 7373ed249d..2920c217f0 100644
--- a/src/index/coinstatsindex.cpp
+++ b/src/index/coinstatsindex.cpp
@@ -299,23 +299,23 @@ bool CoinStatsIndex::Rewind(const CBlockIndex* current_tip, const CBlockIndex* n
return BaseIndex::Rewind(current_tip, new_tip);
}
-static bool LookUpOne(const CDBWrapper& db, const CBlockIndex* block_index, DBVal& result)
+static bool LookUpOne(const CDBWrapper& db, const interfaces::BlockKey& block, DBVal& result)
{
// First check if the result is stored under the height index and the value
// there matches the block hash. This should be the case if the block is on
// the active chain.
std::pair<uint256, DBVal> read_out;
- if (!db.Read(DBHeightKey(block_index->nHeight), read_out)) {
+ if (!db.Read(DBHeightKey(block.height), read_out)) {
return false;
}
- if (read_out.first == block_index->GetBlockHash()) {
+ if (read_out.first == block.hash) {
result = std::move(read_out.second);
return true;
}
// If value at the height index corresponds to an different block, the
// result will be stored in the hash index.
- return db.Read(DBHashKey(block_index->GetBlockHash()), result);
+ return db.Read(DBHashKey(block.hash), result);
}
std::optional<CCoinsStats> CoinStatsIndex::LookUpStats(const CBlockIndex* block_index) const
@@ -324,7 +324,7 @@ std::optional<CCoinsStats> CoinStatsIndex::LookUpStats(const CBlockIndex* block_
stats.index_used = true;
DBVal entry;
- if (!LookUpOne(*m_db, block_index, entry)) {
+ if (!LookUpOne(*m_db, {block_index->GetBlockHash(), block_index->nHeight}, entry)) {
return std::nullopt;
}
@@ -363,7 +363,7 @@ bool CoinStatsIndex::Init()
if (pindex) {
DBVal entry;
- if (!LookUpOne(*m_db, pindex, entry)) {
+ if (!LookUpOne(*m_db, {pindex->GetBlockHash(), pindex->nHeight}, entry)) {
return error("%s: Cannot read current %s state; index may be corrupted",
__func__, GetName());
}