Index: Return early from failed coinstatsindex init

This commit is contained in:
Fabian Jahr 2021-05-24 01:24:05 +02:00
parent 1e3842385b
commit 01386bfd88
No known key found for this signature in database
GPG key ID: F13D1E9D890798CD

View file

@ -344,33 +344,31 @@ bool CoinStatsIndex::Init()
} }
} }
if (BaseIndex::Init()) { if (!BaseIndex::Init()) return false;
const CBlockIndex* pindex{CurrentIndex()};
if (pindex) { const CBlockIndex* pindex{CurrentIndex()};
DBVal entry;
if (!LookUpOne(*m_db, pindex, entry)) {
return false;
}
m_transaction_output_count = entry.transaction_output_count; if (pindex) {
m_bogo_size = entry.bogo_size; DBVal entry;
m_total_amount = entry.total_amount; if (!LookUpOne(*m_db, pindex, entry)) {
m_total_subsidy = entry.total_subsidy; return false;
m_total_unspendable_amount = entry.total_unspendable_amount;
m_total_prevout_spent_amount = entry.total_prevout_spent_amount;
m_total_new_outputs_ex_coinbase_amount = entry.total_new_outputs_ex_coinbase_amount;
m_total_coinbase_amount = entry.total_coinbase_amount;
m_total_unspendables_genesis_block = entry.total_unspendables_genesis_block;
m_total_unspendables_bip30 = entry.total_unspendables_bip30;
m_total_unspendables_scripts = entry.total_unspendables_scripts;
m_total_unspendables_unclaimed_rewards = entry.total_unspendables_unclaimed_rewards;
} }
return true; m_transaction_output_count = entry.transaction_output_count;
m_bogo_size = entry.bogo_size;
m_total_amount = entry.total_amount;
m_total_subsidy = entry.total_subsidy;
m_total_unspendable_amount = entry.total_unspendable_amount;
m_total_prevout_spent_amount = entry.total_prevout_spent_amount;
m_total_new_outputs_ex_coinbase_amount = entry.total_new_outputs_ex_coinbase_amount;
m_total_coinbase_amount = entry.total_coinbase_amount;
m_total_unspendables_genesis_block = entry.total_unspendables_genesis_block;
m_total_unspendables_bip30 = entry.total_unspendables_bip30;
m_total_unspendables_scripts = entry.total_unspendables_scripts;
m_total_unspendables_unclaimed_rewards = entry.total_unspendables_unclaimed_rewards;
} }
return false; return true;
} }
// Reverse a single block as part of a reorg // Reverse a single block as part of a reorg