1
0
Fork 0
forked from lthn/blockchain

get rid of coinday_weight

This commit is contained in:
sowle 2021-10-08 08:01:59 +03:00
parent d5e250d33a
commit 9bfc9a0490
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
6 changed files with 10 additions and 25 deletions

View file

@ -64,11 +64,6 @@ namespace currency
pos_entry());
}*/
//---------------------------------------------------------------
uint64_t get_coinday_weight(uint64_t amount)
{
return amount;
}
//---------------------------------------------------------------
wide_difficulty_type correct_difficulty_with_sequence_factor(size_t sequence_factor, wide_difficulty_type diff)
{
//delta=delta*(0.75^n)

View file

@ -346,7 +346,6 @@ namespace currency
//PoS
bool is_pos_block(const block& b);
bool is_pos_block(const transaction& tx);
uint64_t get_coinday_weight(uint64_t amount);
wide_difficulty_type correct_difficulty_with_sequence_factor(size_t sequence_factor, wide_difficulty_type diff);
void print_currency_details();
std::string print_reward_change_first_blocks(size_t n_of_first_blocks);

View file

@ -3377,16 +3377,13 @@ bool wallet2::prepare_and_sign_pos_block(currency::block& b,
return true;
}
//------------------------------------------------------------------
bool wallet2::build_kernel(const pos_entry& pe, const stake_modifier_type& stake_modifier, stake_kernel& kernel, uint64_t& coindays_weight, uint64_t timestamp)
bool wallet2::build_kernel(const pos_entry& pe, const stake_modifier_type& stake_modifier, const uint64_t timestamp, stake_kernel& kernel)
{
PROFILE_FUNC("build_kernel");
coindays_weight = 0;
kernel = stake_kernel();
kernel.kimage = pe.keyimage;
kernel.stake_modifier = stake_modifier;
kernel.block_timestamp = timestamp;
coindays_weight = get_coinday_weight(pe.amount);
return true;
}
//----------------------------------------------------------------------------------------------------

View file

@ -920,7 +920,7 @@ private:
void handle_pulled_blocks(size_t& blocks_added, std::atomic<bool>& stop,
currency::COMMAND_RPC_GET_BLOCKS_DIRECT::response& blocks);
std::string get_alias_for_address(const std::string& addr);
static bool build_kernel(const currency::pos_entry& pe, const currency::stake_modifier_type& stake_modifier, currency::stake_kernel& kernel, uint64_t& coindays_weight, uint64_t timestamp);
static bool build_kernel(const currency::pos_entry& pe, const currency::stake_modifier_type& stake_modifier, const uint64_t timestamp, currency::stake_kernel& kernel);
bool is_connected_to_net();
bool is_transfer_okay_for_pos(const transfer_details& tr, uint64_t& stake_unlock_time);
bool scan_unconfirmed_outdate_tx();
@ -1258,27 +1258,27 @@ namespace tools
if (stop)
return false;
currency::stake_kernel sk = AUTO_VAL_INIT(sk);
uint64_t coindays_weight = 0;
build_kernel(cxt.sp.pos_entries[i], cxt.sm, sk, coindays_weight, ts);
const uint64_t& stake_amount = cxt.sp.pos_entries[i].amount;
build_kernel(cxt.sp.pos_entries[i], cxt.sm, ts, sk);
crypto::hash kernel_hash;
{
PROFILE_FUNC("calc_hash");
kernel_hash = crypto::cn_fast_hash(&sk, sizeof(sk));
}
currency::wide_difficulty_type this_coin_diff = cxt.basic_diff / coindays_weight;
currency::wide_difficulty_type final_diff = cxt.basic_diff / stake_amount;
bool check_hash_res;
{
PROFILE_FUNC("check_hash");
check_hash_res = currency::check_hash(kernel_hash, this_coin_diff);
check_hash_res = currency::check_hash(kernel_hash, final_diff);
++cxt.rsp.iterations_processed;
}
if (check_hash_res)
{
//found kernel
LOG_PRINT_GREEN("Found kernel: amount=" << currency::print_money(cxt.sp.pos_entries[i].amount) << ENDL
<< "difficulty_basic=" << cxt.basic_diff << ", diff for this coin: " << this_coin_diff << ENDL
<< "index=" << cxt.sp.pos_entries[i].index << ENDL
LOG_PRINT_GREEN("Found kernel: amount: " << currency::print_money(stake_amount) << ENDL
<< "difficulty: " << cxt.basic_diff << ", final_diff: " << final_diff << ENDL
<< "index: " << cxt.sp.pos_entries[i].index << ENDL
<< "kernel info: " << ENDL
<< print_stake_kernel_info(sk) << ENDL
<< "kernel_hash(proof): " << kernel_hash,

View file

@ -563,17 +563,15 @@ bool test_generator::find_kernel(const std::list<currency::account_base>& accs,
{
stake_kernel sk = AUTO_VAL_INIT(sk);
uint64_t coindays_weight = 0;
build_kernel(scan_pos_entries.pos_entries[i].amount,
scan_pos_entries.pos_entries[i].index,
scan_pos_entries.pos_entries[i].keyimage,
sk,
coindays_weight,
blck_chain,
indexes,
ts);
crypto::hash kernel_hash = crypto::cn_fast_hash(&sk, sizeof(sk));
wide_difficulty_type this_coin_diff = basic_diff / coindays_weight;
wide_difficulty_type this_coin_diff = basic_diff / scan_pos_entries.pos_entries[i].amount;
if (!check_hash(kernel_hash, this_coin_diff))
continue;
else
@ -672,12 +670,10 @@ bool test_generator::build_kernel(uint64_t amount,
uint64_t global_index,
const crypto::key_image& ki,
stake_kernel& kernel,
uint64_t& coindays_weight,
const test_generator::blockchain_vector& blck_chain,
const test_generator::outputs_index& indexes,
uint64_t timestamp)
{
coindays_weight = 0;
kernel = stake_kernel();
kernel.kimage = ki;
@ -701,7 +697,6 @@ bool test_generator::build_kernel(uint64_t amount,
kernel.block_timestamp = timestamp;
coindays_weight = get_coinday_weight(amount);
build_stake_modifier(kernel.stake_modifier, blck_chain);
return true;
}

View file

@ -410,7 +410,6 @@ public:
uint64_t global_index,
const crypto::key_image& ki,
currency::stake_kernel& kernel,
uint64_t& coindays_weight,
const blockchain_vector& blck_chain,
const outputs_index& indexes,
uint64_t timestamp);