@@ -265,25 +265,24 @@ static bool CopyHeightIndexToHashIndex(CDBIterator& db_it, CDBBatch& batch,
265265 return true ;
266266}
267267
268- bool CoinStatsIndex::Rewind (const CBlockIndex* current_tip, const CBlockIndex* new_tip)
268+ bool CoinStatsIndex::CustomRewind (const interfaces::BlockKey& current_tip, const interfaces::BlockKey& new_tip)
269269{
270- assert (current_tip->GetAncestor (new_tip->nHeight ) == new_tip);
271-
272270 CDBBatch batch (*m_db);
273271 std::unique_ptr<CDBIterator> db_it (m_db->NewIterator ());
274272
275273 // During a reorg, we need to copy all hash digests for blocks that are
276274 // getting disconnected from the height index to the hash index so we can
277275 // still find them when the height index entries are overwritten.
278- if (!CopyHeightIndexToHashIndex (*db_it, batch, m_name, new_tip-> nHeight , current_tip-> nHeight )) {
276+ if (!CopyHeightIndexToHashIndex (*db_it, batch, m_name, new_tip. height , current_tip. height )) {
279277 return false ;
280278 }
281279
282280 if (!m_db->WriteBatch (batch)) return false ;
283281
284282 {
285283 LOCK (cs_main);
286- const CBlockIndex* iter_tip{m_chainstate->m_blockman .LookupBlockIndex (current_tip->GetBlockHash ())};
284+ const CBlockIndex* iter_tip{m_chainstate->m_blockman .LookupBlockIndex (current_tip.hash )};
285+ const CBlockIndex* new_tip_index{m_chainstate->m_blockman .LookupBlockIndex (new_tip.hash )};
287286 const auto & consensus_params{Params ().GetConsensus ()};
288287
289288 do {
@@ -297,10 +296,10 @@ bool CoinStatsIndex::Rewind(const CBlockIndex* current_tip, const CBlockIndex* n
297296 ReverseBlock (block, iter_tip);
298297
299298 iter_tip = iter_tip->GetAncestor (iter_tip->nHeight - 1 );
300- } while (new_tip != iter_tip);
299+ } while (new_tip_index != iter_tip);
301300 }
302301
303- return BaseIndex::Rewind (current_tip, new_tip) ;
302+ return true ;
304303}
305304
306305static bool LookUpOne (const CDBWrapper& db, const interfaces::BlockKey& block, DBVal& result)
0 commit comments