1
0
Fork 0
forked from lthn/blockchain

fixed bug in is_reorganize_required

This commit is contained in:
cryptozoidberg 2019-08-08 21:15:09 +02:00
parent 521ffa7904
commit 58c0fff1de
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
2 changed files with 6 additions and 6 deletions

View file

@ -1609,7 +1609,7 @@ bool blockchain_storage::handle_alternative_block(const block& b, const crypto::
abei.cumulative_diff_adjusted += cumulative_diff_delta;
wide_difficulty_type last_x_cumul_dif_precise_adj = 0;
abei.cumulative_diff_precise = get_last_alt_x_block_cumulative_precise_difficulty(alt_chain, abei.height, pos_block, last_x_cumul_dif_precise_adj);
abei.cumulative_diff_precise = get_last_alt_x_block_cumulative_precise_difficulty(alt_chain, abei.height-1, pos_block, last_x_cumul_dif_precise_adj);
abei.cumulative_diff_precise += current_diff;
//////////////////////////////////////////////////////////////////////////
@ -4635,7 +4635,7 @@ wide_difficulty_type blockchain_storage::get_last_alt_x_block_cumulative_precise
//------------------------------------------------------------------
wide_difficulty_type blockchain_storage::get_last_alt_x_block_cumulative_precise_difficulty(const alt_chain_type& alt_chain, uint64_t block_height, bool pos, wide_difficulty_type& cumulative_diff_precise_adj) const
{
uint64_t main_chain_first_block = block_height - 1;
uint64_t main_chain_first_block = block_height;
for (auto it = alt_chain.rbegin(); it != alt_chain.rend(); it++)
{
if (is_pos_block((*it)->second.bl) == pos)

View file

@ -2709,10 +2709,10 @@ namespace currency
const difficulties& a_diff,
const difficulties& b_diff )
{
const wide_difficulty_type& a_pos_cumulative_difficulty = a_diff.pos_diff;
const wide_difficulty_type& b_pos_cumulative_difficulty = b_diff.pos_diff;
const wide_difficulty_type& a_pow_cumulative_difficulty = a_diff.pow_diff;
const wide_difficulty_type& b_pow_cumulative_difficulty = b_diff.pow_diff;
const wide_difficulty_type& a_pos_cumulative_difficulty = a_diff.pos_diff != 0 ? a_diff.pos_diff:DIFFICULTY_STARTER;
const wide_difficulty_type& b_pos_cumulative_difficulty = b_diff.pos_diff != 0 ? b_diff.pos_diff : DIFFICULTY_STARTER;
const wide_difficulty_type& a_pow_cumulative_difficulty = a_diff.pow_diff != 0 ? a_diff.pow_diff : DIFFICULTY_STARTER;
const wide_difficulty_type& b_pow_cumulative_difficulty = b_diff.pow_diff != 0 ? b_diff.pow_diff : DIFFICULTY_STARTER;
boost::multiprecision::uint1024_t basic_sum = boost::multiprecision::uint1024_t(a_pow_cumulative_difficulty) + (boost::multiprecision::uint1024_t(a_pos_cumulative_difficulty)*difficulty_pow_at_split_point) / difficulty_pos_at_split_point;
boost::multiprecision::uint1024_t res =