@@ -299,23 +299,23 @@ bool CoinStatsIndex::Rewind(const CBlockIndex* current_tip, const CBlockIndex* n
299
299
return BaseIndex::Rewind (current_tip, new_tip);
300
300
}
301
301
302
- static bool LookUpOne (const CDBWrapper& db, const CBlockIndex* block_index , DBVal& result)
302
+ static bool LookUpOne (const CDBWrapper& db, const interfaces::BlockKey& block , DBVal& result)
303
303
{
304
304
// First check if the result is stored under the height index and the value
305
305
// there matches the block hash. This should be the case if the block is on
306
306
// the active chain.
307
307
std::pair<uint256, DBVal> read_out;
308
- if (!db.Read (DBHeightKey (block_index-> nHeight ), read_out)) {
308
+ if (!db.Read (DBHeightKey (block. height ), read_out)) {
309
309
return false ;
310
310
}
311
- if (read_out.first == block_index-> GetBlockHash () ) {
311
+ if (read_out.first == block. hash ) {
312
312
result = std::move (read_out.second );
313
313
return true ;
314
314
}
315
315
316
316
// If value at the height index corresponds to an different block, the
317
317
// result will be stored in the hash index.
318
- return db.Read (DBHashKey (block_index-> GetBlockHash () ), result);
318
+ return db.Read (DBHashKey (block. hash ), result);
319
319
}
320
320
321
321
std::optional<CCoinsStats> CoinStatsIndex::LookUpStats (const CBlockIndex* block_index) const
@@ -324,7 +324,7 @@ std::optional<CCoinsStats> CoinStatsIndex::LookUpStats(const CBlockIndex* block_
324
324
stats.index_used = true ;
325
325
326
326
DBVal entry;
327
- if (!LookUpOne (*m_db, block_index, entry)) {
327
+ if (!LookUpOne (*m_db, { block_index-> GetBlockHash (), block_index-> nHeight } , entry)) {
328
328
return std::nullopt;
329
329
}
330
330
@@ -363,7 +363,7 @@ bool CoinStatsIndex::Init()
363
363
364
364
if (pindex) {
365
365
DBVal entry;
366
- if (!LookUpOne (*m_db, pindex, entry)) {
366
+ if (!LookUpOne (*m_db, { pindex-> GetBlockHash (), pindex-> nHeight } , entry)) {
367
367
return error (" %s: Cannot read current %s state; index may be corrupted" ,
368
368
__func__, GetName ());
369
369
}
0 commit comments