index: Don't commit without valid m_best_block_index
Also report an error when coinstatsindex init fails.
This commit is contained in:
1 parent
8f137e69ca
commit
0243907fae
2 files changed
+7
-2
No files matched your search
@@ -211,6 +211,11 @@ bool BaseIndex::Commit()
|
|||||||
bool BaseIndex::CommitInternal(CDBBatch& batch)
|
bool BaseIndex::CommitInternal(CDBBatch& batch)
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
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));
|
GetDB().WriteBestBlock(batch, m_chainstate->m_chain.GetLocator(m_best_block_index));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -360,9 +360,9 @@ bool CoinStatsIndex::Init()
|
|||||||
if (pindex) {
|
if (pindex) {
|
||||||
DBVal entry;
|
DBVal entry;
|
||||||
if (!LookUpOne(*m_db, pindex, 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_transaction_output_count = entry.transaction_output_count;
|
||||||
m_bogo_size = entry.bogo_size;
|
m_bogo_size = entry.bogo_size;
|
||||||
m_total_amount = entry.total_amount;
|
m_total_amount = entry.total_amount;
|
||||||
|
|||||||
Reference in new issue
Block a user