Skip to content

Commit

Permalink
index: Add temporary workaround to resolve txindex crash issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lateminer committed Nov 17, 2024
1 parent 434ec31 commit de3e073
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/index/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,19 @@ bool BaseIndex::Init()
// best chain, we will rewind to the fork point during index sync
const CBlockIndex* locator_index{m_chainstate->m_blockman.LookupBlockIndex(locator.vHave.at(0))};
if (!locator_index) {
return InitError(strprintf(Untranslated("%s: best block of the index not found. Please rebuild the index."), GetName()));
/*
// Blackcoin ToDo: that's a temporary workaround for issue https://github.com/CoinBlack/blackcoin-more/issues/22
// This addresses blockfilterindex and txindex crash issues but does not help to deal with the coinstatsindex crash
// A more robust solution should replace this in the future
*/
// If we couldn't find a block index from the locator, use m_best_header as a fallback
const CBlockIndex* best_header = index_chain.Tip();
if (best_header) {
locator_index = best_header;
LogPrintf("%s: Using m_best_header as fallback, block hash: %s at height %d\n", GetName(), locator_index->GetBlockHash().ToString(), locator_index->nHeight);
} else {
return InitError(strprintf(Untranslated("%s: best block of the index not found. Please rebuild the index."), GetName()));
}
}
SetBestBlockIndex(locator_index);
}
Expand Down

0 comments on commit de3e073

Please sign in to comment.