mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-28 17:53:04 +02:00
index: Don't commit without valid m_best_block_index
Also report an error when coinstatsindex init fails.
This commit is contained in:
@@ -211,6 +211,11 @@ bool BaseIndex::Commit()
|
||||
bool BaseIndex::CommitInternal(CDBBatch& batch)
|
||||
{
|
||||
LOCK(cs_main);
|
||||
// Don't commit anything if we haven't indexed any block yet
|
||||
// (this could happen if init is interrupted).
|
||||
if (m_best_block_index == nullptr) {
|
||||
return false;
|
||||
}
|
||||
GetDB().WriteBestBlock(batch, m_chainstate->m_chain.GetLocator(m_best_block_index));
|
||||
return true;
|
||||
}
|
||||
|
@@ -360,9 +360,9 @@ bool CoinStatsIndex::Init()
|
||||
if (pindex) {
|
||||
DBVal entry;
|
||||
if (!LookUpOne(*m_db, pindex, entry)) {
|
||||
return false;
|
||||
return error("%s: Cannot read current %s state; index may be corrupted",
|
||||
__func__, GetName());
|
||||
}
|
||||
|
||||
m_transaction_output_count = entry.transaction_output_count;
|
||||
m_bogo_size = entry.bogo_size;
|
||||
m_total_amount = entry.total_amount;
|
||||
|
Reference in New Issue
Block a user