|
|
|
@ -428,7 +428,7 @@ bool Blockchain::init(BlockchainDB* db, const network_type nettype, bool offline
|
|
|
|
|
{
|
|
|
|
|
MINFO("Blockchain not loaded, generating genesis block.");
|
|
|
|
|
block bl;
|
|
|
|
|
block_verification_context bvc = boost::value_initialized<block_verification_context>();
|
|
|
|
|
block_verification_context bvc = {};
|
|
|
|
|
generate_genesis_block(bl, get_config(m_nettype).GENESIS_TX, get_config(m_nettype).GENESIS_NONCE);
|
|
|
|
|
db_wtxn_guard wtxn_guard(m_db);
|
|
|
|
|
add_new_block(bl, bvc);
|
|
|
|
@ -736,7 +736,7 @@ bool Blockchain::reset_and_set_genesis_block(const block& b)
|
|
|
|
|
m_hardfork->init();
|
|
|
|
|
|
|
|
|
|
db_wtxn_guard wtxn_guard(m_db);
|
|
|
|
|
block_verification_context bvc = boost::value_initialized<block_verification_context>();
|
|
|
|
|
block_verification_context bvc = {};
|
|
|
|
|
add_new_block(b, bvc);
|
|
|
|
|
if (!update_next_cumulative_weight_limit())
|
|
|
|
|
return false;
|
|
|
|
@ -1006,7 +1006,7 @@ bool Blockchain::rollback_blockchain_switching(std::list<block>& original_chain,
|
|
|
|
|
//return back original chain
|
|
|
|
|
for (auto& bl : original_chain)
|
|
|
|
|
{
|
|
|
|
|
block_verification_context bvc = boost::value_initialized<block_verification_context>();
|
|
|
|
|
block_verification_context bvc = {};
|
|
|
|
|
bool r = handle_block_to_main_chain(bl, bvc);
|
|
|
|
|
CHECK_AND_ASSERT_MES(r && bvc.m_added_to_main_chain, false, "PANIC! failed to add (again) block while chain switching during the rollback!");
|
|
|
|
|
}
|
|
|
|
@ -1055,7 +1055,7 @@ bool Blockchain::switch_to_alternative_blockchain(std::list<block_extended_info>
|
|
|
|
|
for(auto alt_ch_iter = alt_chain.begin(); alt_ch_iter != alt_chain.end(); alt_ch_iter++)
|
|
|
|
|
{
|
|
|
|
|
const auto &bei = *alt_ch_iter;
|
|
|
|
|
block_verification_context bvc = boost::value_initialized<block_verification_context>();
|
|
|
|
|
block_verification_context bvc = {};
|
|
|
|
|
|
|
|
|
|
// add block to main chain
|
|
|
|
|
bool r = handle_block_to_main_chain(bei.bl, bvc);
|
|
|
|
@ -1098,7 +1098,7 @@ bool Blockchain::switch_to_alternative_blockchain(std::list<block_extended_info>
|
|
|
|
|
//pushing old chain as alternative chain
|
|
|
|
|
for (auto& old_ch_ent : disconnected_chain)
|
|
|
|
|
{
|
|
|
|
|
block_verification_context bvc = boost::value_initialized<block_verification_context>();
|
|
|
|
|
block_verification_context bvc = {};
|
|
|
|
|
bool r = handle_alternative_block(old_ch_ent, get_block_hash(old_ch_ent), bvc);
|
|
|
|
|
if(!r)
|
|
|
|
|
{
|
|
|
|
@ -1412,7 +1412,7 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block,
|
|
|
|
|
|
|
|
|
|
//we have new block in alternative chain
|
|
|
|
|
std::list<block_extended_info> alt_chain;
|
|
|
|
|
block_verification_context bvc = boost::value_initialized<block_verification_context>();
|
|
|
|
|
block_verification_context bvc = {};
|
|
|
|
|
std::vector<uint64_t> timestamps;
|
|
|
|
|
if (!build_alt_chain(*from_block, alt_chain, timestamps, bvc))
|
|
|
|
|
return false;
|
|
|
|
@ -1446,7 +1446,7 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FIXME: consider moving away from block_extended_info at some point
|
|
|
|
|
block_extended_info bei = boost::value_initialized<block_extended_info>();
|
|
|
|
|
block_extended_info bei = {};
|
|
|
|
|
bei.bl = b;
|
|
|
|
|
bei.height = alt_chain.size() ? prev_data.height + 1 : m_db->get_block_height(*from_block) + 1;
|
|
|
|
|
|
|
|
|
@ -1733,7 +1733,7 @@ bool Blockchain::handle_alternative_block(const block& b, const crypto::hash& id
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// FIXME: consider moving away from block_extended_info at some point
|
|
|
|
|
block_extended_info bei = boost::value_initialized<block_extended_info>();
|
|
|
|
|
block_extended_info bei = {};
|
|
|
|
|
bei.bl = b;
|
|
|
|
|
const uint64_t prev_height = alt_chain.size() ? prev_data.height : m_db->get_block_height(b.prev_id);
|
|
|
|
|
bei.height = prev_height + 1;
|
|
|
|
|