forked from lthn/blockchain
minor improvements
This commit is contained in:
parent
56a265bd48
commit
6be32747c7
3 changed files with 11 additions and 5 deletions
|
|
@ -7508,11 +7508,11 @@ bool blockchain_storage::add_new_block(const block& bl, block_verification_conte
|
|||
}
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::truncate_blockchain(uint64_t to_height)
|
||||
bool blockchain_storage::truncate_blockchain(uint64_t to_blockchain_size)
|
||||
{
|
||||
m_db.begin_transaction();
|
||||
uint64_t inital_height = get_current_blockchain_size();
|
||||
while (get_current_blockchain_size() > to_height)
|
||||
uint64_t inital_blockchain_size = get_current_blockchain_size();
|
||||
while (get_current_blockchain_size() > to_blockchain_size)
|
||||
{
|
||||
transactions_map ot;
|
||||
pop_block_from_blockchain(ot);
|
||||
|
|
@ -7521,7 +7521,7 @@ bool blockchain_storage::truncate_blockchain(uint64_t to_height)
|
|||
m_alternative_chains.clear();
|
||||
m_altblocks_keyimages.clear();
|
||||
m_alternative_chains_txs.clear();
|
||||
LOG_PRINT_MAGENTA("Blockchain truncated from " << inital_height << " to " << get_current_blockchain_size(), LOG_LEVEL_0);
|
||||
LOG_PRINT_MAGENTA("Blockchain truncated from size " << inital_blockchain_size << " to size " << get_current_blockchain_size() << ". Alt blocks cleared.", LOG_LEVEL_0);
|
||||
m_db.commit_transaction();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ namespace currency
|
|||
bool clear();
|
||||
bool reset_and_set_genesis_block(const block& b);
|
||||
//debug function
|
||||
bool truncate_blockchain(uint64_t to_height);
|
||||
bool truncate_blockchain(uint64_t to_blockchain_size);
|
||||
//------------- readers members -----------------
|
||||
bool pre_validate_relayed_block(block& b, block_verification_context& bvc, const crypto::hash& id)const ;
|
||||
//bool push_new_block();
|
||||
|
|
|
|||
|
|
@ -55,6 +55,12 @@ namespace currency
|
|||
return epee::string_tools::num_to_string_fast(m_height_the_hardfork_n_active_after[hardfork_id]);
|
||||
}
|
||||
|
||||
uint64_t get_height_the_hardfork_active_after(size_t hardfork_id) const
|
||||
{
|
||||
CHECK_AND_ASSERT_THROW_MES(hardfork_id < m_total_count, "invalid hardfork id: " << hardfork_id);
|
||||
return m_height_the_hardfork_n_active_after[hardfork_id];
|
||||
}
|
||||
|
||||
size_t get_the_most_recent_hardfork_id_for_height(uint64_t height) const
|
||||
{
|
||||
for(size_t hid = m_total_count - 1; hid != 0; --hid) // 0 is not including
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue