mirror of
https://github.com/monero-project/monero.git
synced 2024-12-25 04:59:43 +00:00
blockchain_storage: refactor genesis block creation
The existing assert is kept as it is stricter than the function's internal assert.
This commit is contained in:
parent
8e41b1e735
commit
a3157d7b69
2 changed files with 6 additions and 16 deletions
|
@ -113,24 +113,14 @@ bool blockchain_storage::init(const std::string& config_folder, bool testnet)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_PRINT_L0("Can't load blockchain storage from file, generating genesis block.");
|
LOG_PRINT_L0("Can't load blockchain storage from file, generating genesis block.");
|
||||||
block bl = boost::value_initialized<block>();
|
if (!store_genesis_block(testnet, true))
|
||||||
block_verification_context bvc = boost::value_initialized<block_verification_context>();
|
return false;
|
||||||
if (testnet)
|
|
||||||
{
|
|
||||||
generate_genesis_block(bl, config::testnet::GENESIS_TX, config::testnet::GENESIS_NONCE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
generate_genesis_block(bl, config::GENESIS_TX, config::GENESIS_NONCE);
|
|
||||||
}
|
|
||||||
add_new_block(bl, bvc);
|
|
||||||
CHECK_AND_ASSERT_MES(!bvc.m_verifivation_failed && bvc.m_added_to_main_chain, false, "Failed to add genesis block to blockchain");
|
|
||||||
}
|
}
|
||||||
if(!m_blocks.size())
|
if(!m_blocks.size())
|
||||||
{
|
{
|
||||||
LOG_PRINT_L0("Blockchain not loaded, generating genesis block.");
|
LOG_PRINT_L0("Blockchain not loaded, generating genesis block.");
|
||||||
|
|
||||||
if (!store_genesis_block(testnet)) {
|
if (!store_genesis_block(testnet, false)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -159,7 +149,7 @@ bool blockchain_storage::init(const std::string& config_folder, bool testnet)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
bool blockchain_storage::store_genesis_block(bool testnet) {
|
bool blockchain_storage::store_genesis_block(bool testnet, bool check_added) {
|
||||||
block bl = ::boost::value_initialized<block>();
|
block bl = ::boost::value_initialized<block>();
|
||||||
block_verification_context bvc = boost::value_initialized<block_verification_context>();
|
block_verification_context bvc = boost::value_initialized<block_verification_context>();
|
||||||
|
|
||||||
|
@ -173,7 +163,7 @@ bool blockchain_storage::store_genesis_block(bool testnet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
add_new_block(bl, bvc);
|
add_new_block(bl, bvc);
|
||||||
CHECK_AND_ASSERT_MES(!bvc.m_verifivation_failed, false, "Failed to add genesis block to blockchain");
|
CHECK_AND_ASSERT_MES(!bvc.m_verifivation_failed && (bvc.m_added_to_main_chain || !check_added), false, "Failed to add genesis block to blockchain");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
|
@ -252,7 +252,7 @@ namespace cryptonote
|
||||||
uint64_t get_adjusted_time() const;
|
uint64_t get_adjusted_time() const;
|
||||||
bool complete_timestamps_vector(uint64_t start_height, std::vector<uint64_t>& timestamps) const;
|
bool complete_timestamps_vector(uint64_t start_height, std::vector<uint64_t>& timestamps) const;
|
||||||
bool update_next_comulative_size_limit();
|
bool update_next_comulative_size_limit();
|
||||||
bool store_genesis_block(bool testnet);
|
bool store_genesis_block(bool testnet, bool check_added = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue