Skip to content

Commit de3e073

Browse files
committed
index: Add temporary workaround to resolve txindex crash issue
1 parent 434ec31 commit de3e073

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/index/base.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,19 @@ bool BaseIndex::Init()
107107
// best chain, we will rewind to the fork point during index sync
108108
const CBlockIndex* locator_index{m_chainstate->m_blockman.LookupBlockIndex(locator.vHave.at(0))};
109109
if (!locator_index) {
110-
return InitError(strprintf(Untranslated("%s: best block of the index not found. Please rebuild the index."), GetName()));
110+
/*
111+
// Blackcoin ToDo: that's a temporary workaround for issue https://github.com/CoinBlack/blackcoin-more/issues/22
112+
// This addresses blockfilterindex and txindex crash issues but does not help to deal with the coinstatsindex crash
113+
// A more robust solution should replace this in the future
114+
*/
115+
// If we couldn't find a block index from the locator, use m_best_header as a fallback
116+
const CBlockIndex* best_header = index_chain.Tip();
117+
if (best_header) {
118+
locator_index = best_header;
119+
LogPrintf("%s: Using m_best_header as fallback, block hash: %s at height %d\n", GetName(), locator_index->GetBlockHash().ToString(), locator_index->nHeight);
120+
} else {
121+
return InitError(strprintf(Untranslated("%s: best block of the index not found. Please rebuild the index."), GetName()));
122+
}
111123
}
112124
SetBestBlockIndex(locator_index);
113125
}

0 commit comments

Comments
 (0)