forked from lthn/blockchain
fixed relative_cumulative_difficulty issue
This commit is contained in:
parent
8ee45350ab
commit
ef8f61fbc4
3 changed files with 17 additions and 17 deletions
|
|
@ -1821,8 +1821,8 @@ bool blockchain_storage::is_reorganize_required(const block_extended_info& main_
|
|||
main_cumul_diff.pow_diff = main_pow_diff_end - main_pow_diff_begin;
|
||||
|
||||
//TODO: measurement of precise cumulative difficult
|
||||
wide_difficulty_type alt = get_a_to_b_relative_cumulative_difficulty(difficulty_pos_at_split_point, difficulty_pow_at_split_point, alt_cumul_diff, main_cumul_diff);
|
||||
wide_difficulty_type main = get_a_to_b_relative_cumulative_difficulty(difficulty_pos_at_split_point, difficulty_pow_at_split_point, main_cumul_diff, alt_cumul_diff);
|
||||
boost::multiprecision::uint1024_t alt = get_a_to_b_relative_cumulative_difficulty(difficulty_pos_at_split_point, difficulty_pow_at_split_point, alt_cumul_diff, main_cumul_diff);
|
||||
boost::multiprecision::uint1024_t main = get_a_to_b_relative_cumulative_difficulty(difficulty_pos_at_split_point, difficulty_pow_at_split_point, main_cumul_diff, alt_cumul_diff);
|
||||
LOG_PRINT_L1("[FORK_CHOICE]: " << ENDL
|
||||
<< "difficulty_pow_at_split_point:" << difficulty_pow_at_split_point << ENDL
|
||||
<< "difficulty_pos_at_split_point:" << difficulty_pos_at_split_point << ENDL
|
||||
|
|
|
|||
|
|
@ -2702,7 +2702,7 @@ namespace currency
|
|||
}
|
||||
|
||||
|
||||
wide_difficulty_type get_a_to_b_relative_cumulative_difficulty(const wide_difficulty_type& difficulty_pos_at_split_point,
|
||||
boost::multiprecision::uint1024_t get_a_to_b_relative_cumulative_difficulty(const wide_difficulty_type& difficulty_pos_at_split_point,
|
||||
const wide_difficulty_type& difficulty_pow_at_split_point,
|
||||
const difficulties& a_diff,
|
||||
const difficulties& b_diff )
|
||||
|
|
@ -2717,20 +2717,20 @@ namespace currency
|
|||
boost::multiprecision::uint1024_t res =
|
||||
(basic_sum * a_pow_cumulative_difficulty * a_pos_cumulative_difficulty) / (boost::multiprecision::uint1024_t(b_pow_cumulative_difficulty)*b_pos_cumulative_difficulty);
|
||||
|
||||
if (res > boost::math::tools::max_value<wide_difficulty_type>())
|
||||
{
|
||||
ASSERT_MES_AND_THROW("[INTERNAL ERROR]: Failed to get_a_to_b_relative_cumulative_difficulty, res = " << res << ENDL
|
||||
<< ", difficulty_pos_at_split_point: " << difficulty_pos_at_split_point << ENDL
|
||||
<< ", difficulty_pow_at_split_point:" << difficulty_pow_at_split_point << ENDL
|
||||
<< ", a_pos_cumulative_difficulty:" << a_pos_cumulative_difficulty << ENDL
|
||||
<< ", b_pos_cumulative_difficulty:" << b_pos_cumulative_difficulty << ENDL
|
||||
<< ", a_pow_cumulative_difficulty:" << a_pow_cumulative_difficulty << ENDL
|
||||
<< ", b_pow_cumulative_difficulty:" << b_pow_cumulative_difficulty << ENDL
|
||||
);
|
||||
}
|
||||
// if (res > boost::math::tools::max_value<wide_difficulty_type>())
|
||||
// {
|
||||
// ASSERT_MES_AND_THROW("[INTERNAL ERROR]: Failed to get_a_to_b_relative_cumulative_difficulty, res = " << res << ENDL
|
||||
// << ", difficulty_pos_at_split_point: " << difficulty_pos_at_split_point << ENDL
|
||||
// << ", difficulty_pow_at_split_point:" << difficulty_pow_at_split_point << ENDL
|
||||
// << ", a_pos_cumulative_difficulty:" << a_pos_cumulative_difficulty << ENDL
|
||||
// << ", b_pos_cumulative_difficulty:" << b_pos_cumulative_difficulty << ENDL
|
||||
// << ", a_pow_cumulative_difficulty:" << a_pow_cumulative_difficulty << ENDL
|
||||
// << ", b_pow_cumulative_difficulty:" << b_pow_cumulative_difficulty << ENDL
|
||||
// );
|
||||
// }
|
||||
TRY_ENTRY();
|
||||
wide_difficulty_type short_res = res.convert_to<wide_difficulty_type>();
|
||||
return short_res;
|
||||
// wide_difficulty_type short_res = res.convert_to<wide_difficulty_type>();
|
||||
return res;
|
||||
CATCH_ENTRY_WITH_FORWARDING_EXCEPTION();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -604,7 +604,7 @@ namespace currency
|
|||
wide_difficulty_type pow_diff;
|
||||
};
|
||||
|
||||
wide_difficulty_type get_a_to_b_relative_cumulative_difficulty(const wide_difficulty_type& difficulty_pos_at_split_point,
|
||||
boost::multiprecision::uint1024_t get_a_to_b_relative_cumulative_difficulty(const wide_difficulty_type& difficulty_pos_at_split_point,
|
||||
const wide_difficulty_type& difficulty_pow_at_split_point,
|
||||
const difficulties& a_diff,
|
||||
const difficulties& b_diff
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue