Skip to content

Commit 1c67b49

Browse files
committed
Fix BaseIndex::Commit false error.
Previously an ERROR was logged every time an index was initialized. Now we only record an error on actual error.
1 parent 8339f3c commit 1c67b49

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/index/base.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,13 @@ bool BaseIndex::Commit()
225225
{
226226
// Don't commit anything if we haven't indexed any block yet
227227
// (this could happen if init is interrupted).
228-
bool ok = m_best_block_index != nullptr;
229-
if (ok) {
228+
if (m_best_block_index != nullptr) {
230229
CDBBatch batch(GetDB());
231-
ok = CustomCommit(batch);
232-
if (ok) {
233-
GetDB().WriteBestBlock(batch, GetLocator(*m_chain, m_best_block_index.load()->GetBlockHash()));
234-
ok = GetDB().WriteBatch(batch);
235-
}
236-
}
237-
if (!ok) {
238-
return error("%s: Failed to commit latest %s state", __func__, GetName());
230+
if (!CustomCommit(batch))
231+
return error("%s: Failed to CustomCommit latest %s state", __func__, GetName());
232+
GetDB().WriteBestBlock(batch, GetLocator(*m_chain, m_best_block_index.load()->GetBlockHash()));
233+
if (!GetDB().WriteBatch(batch))
234+
return error("%s: Failed to commit latest %s state", __func__, GetName());
239235
}
240236
return true;
241237
}

0 commit comments

Comments
 (0)