mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
index: Don't commit without valid m_best_block_index
Also report an error when coinstatsindex init fails.
This commit is contained in:
parent
8f137e69ca
commit
0243907fae
2 changed files with 7 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue