@@ -299,23 +299,23 @@ bool CoinStatsIndex::Rewind(const CBlockIndex* current_tip, const CBlockIndex* n
299299 return BaseIndex::Rewind (current_tip, new_tip);
300300}
301301
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)
303303{
304304 // First check if the result is stored under the height index and the value
305305 // there matches the block hash. This should be the case if the block is on
306306 // the active chain.
307307 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)) {
309309 return false ;
310310 }
311- if (read_out.first == block_index-> GetBlockHash () ) {
311+ if (read_out.first == block. hash ) {
312312 result = std::move (read_out.second );
313313 return true ;
314314 }
315315
316316 // If value at the height index corresponds to an different block, the
317317 // 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);
319319}
320320
321321std::optional<CCoinsStats> CoinStatsIndex::LookUpStats (const CBlockIndex* block_index) const
@@ -324,7 +324,7 @@ std::optional<CCoinsStats> CoinStatsIndex::LookUpStats(const CBlockIndex* block_
324324 stats.index_used = true ;
325325
326326 DBVal entry;
327- if (!LookUpOne (*m_db, block_index, entry)) {
327+ if (!LookUpOne (*m_db, { block_index-> GetBlockHash (), block_index-> nHeight } , entry)) {
328328 return std::nullopt ;
329329 }
330330
@@ -363,7 +363,7 @@ bool CoinStatsIndex::Init()
363363
364364 if (pindex) {
365365 DBVal entry;
366- if (!LookUpOne (*m_db, pindex, entry)) {
366+ if (!LookUpOne (*m_db, { pindex-> GetBlockHash (), pindex-> nHeight } , entry)) {
367367 return error (" %s: Cannot read current %s state; index may be corrupted" ,
368368 __func__, GetName ());
369369 }
0 commit comments