Skip to content

Commit 01386bf

Browse files
committed
Index: Return early from failed coinstatsindex init
1 parent 1e38423 commit 01386bf

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

src/index/coinstatsindex.cpp

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -344,33 +344,31 @@ bool CoinStatsIndex::Init()
344344
}
345345
}
346346

347-
if (BaseIndex::Init()) {
348-
const CBlockIndex* pindex{CurrentIndex()};
347+
if (!BaseIndex::Init()) return false;
349348

350-
if (pindex) {
351-
DBVal entry;
352-
if (!LookUpOne(*m_db, pindex, entry)) {
353-
return false;
354-
}
349+
const CBlockIndex* pindex{CurrentIndex()};
355350

356-
m_transaction_output_count = entry.transaction_output_count;
357-
m_bogo_size = entry.bogo_size;
358-
m_total_amount = entry.total_amount;
359-
m_total_subsidy = entry.total_subsidy;
360-
m_total_unspendable_amount = entry.total_unspendable_amount;
361-
m_total_prevout_spent_amount = entry.total_prevout_spent_amount;
362-
m_total_new_outputs_ex_coinbase_amount = entry.total_new_outputs_ex_coinbase_amount;
363-
m_total_coinbase_amount = entry.total_coinbase_amount;
364-
m_total_unspendables_genesis_block = entry.total_unspendables_genesis_block;
365-
m_total_unspendables_bip30 = entry.total_unspendables_bip30;
366-
m_total_unspendables_scripts = entry.total_unspendables_scripts;
367-
m_total_unspendables_unclaimed_rewards = entry.total_unspendables_unclaimed_rewards;
351+
if (pindex) {
352+
DBVal entry;
353+
if (!LookUpOne(*m_db, pindex, entry)) {
354+
return false;
368355
}
369356

370-
return true;
357+
m_transaction_output_count = entry.transaction_output_count;
358+
m_bogo_size = entry.bogo_size;
359+
m_total_amount = entry.total_amount;
360+
m_total_subsidy = entry.total_subsidy;
361+
m_total_unspendable_amount = entry.total_unspendable_amount;
362+
m_total_prevout_spent_amount = entry.total_prevout_spent_amount;
363+
m_total_new_outputs_ex_coinbase_amount = entry.total_new_outputs_ex_coinbase_amount;
364+
m_total_coinbase_amount = entry.total_coinbase_amount;
365+
m_total_unspendables_genesis_block = entry.total_unspendables_genesis_block;
366+
m_total_unspendables_bip30 = entry.total_unspendables_bip30;
367+
m_total_unspendables_scripts = entry.total_unspendables_scripts;
368+
m_total_unspendables_unclaimed_rewards = entry.total_unspendables_unclaimed_rewards;
371369
}
372370

373-
return false;
371+
return true;
374372
}
375373

376374
// Reverse a single block as part of a reorg

0 commit comments

Comments
 (0)