diff --git a/src/currency_core/blockchain_storage.cpp b/src/currency_core/blockchain_storage.cpp index 6eb446dd..bc2c8a2e 100644 --- a/src/currency_core/blockchain_storage.cpp +++ b/src/currency_core/blockchain_storage.cpp @@ -1424,7 +1424,7 @@ bool blockchain_storage::create_block_template(const create_block_template_param const account_public_address& stakeholder_address = params.stakeholder_address; const blobdata& ex_nonce = params.ex_nonce; bool pos = params.pos; - const pos_entry& pe = params.pe; + pos_entry pe = params.pe; fill_block_template_func_t* pcustom_fill_block_template_func = params.pcustom_fill_block_template_func; diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 7efe2f23..54932aa3 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -283,7 +283,7 @@ namespace currency posin.amount = pe.amount; // TODO: using pe.index is deprecated, get input's global index by pe.tx_id and pe.tx_out_index - posin.key_offsets.push_back(pe.index); + posin.key_offsets.push_back(pe.g_index); posin.k_image = pe.keyimage; tx.vin.push_back(posin); diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index d60cc476..551e3685 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3790,23 +3790,26 @@ bool wallet2::build_minted_block(const mining_context& cxt, //CHECK_AND_NO_ASSERT_MES(cxt.rsp.index < cxt.sp.pos_entries.size(), false, "call_COMMAND_RPC_SCAN_POS returned wrong index: " << cxt.rsp.index << ", expected less then " << cxt.sp.pos_entries.size()); - const pos_entry pe = AUTO_VAL_INIT(); - pe. + pos_entry pe = AUTO_VAL_INIT(pe); + currency::COMMAND_RPC_GETBLOCKTEMPLATE::request tmpl_req = AUTO_VAL_INIT(tmpl_req); currency::COMMAND_RPC_GETBLOCKTEMPLATE::response tmpl_rsp = AUTO_VAL_INIT(tmpl_rsp); tmpl_req.wallet_address = get_account_address_as_str(miner_address); tmpl_req.stakeholder_address = get_account_address_as_str(m_account.get_public_address()); tmpl_req.pos_block = true; - tmpl_req.pos_g_index = m_transfers[cxt.rsp.index].m_global_output_index; - tmpl_req.pos_amount = m_transfers[cxt.rsp.index].amount();// pe.amount; - tmpl_req.tx_id = m_transfers[cxt.rsp.index].tx_hash(); - tmpl_req.tx_out_index = m_transfers[cxt.rsp.index].m_internal_output_index; + pe.g_index = tmpl_req.pos_g_index = m_transfers[cxt.rsp.index].m_global_output_index; + pe.amount = tmpl_req.pos_amount = m_transfers[cxt.rsp.index].amount();// pe.amount; + pe.keyimage = m_transfers[cxt.rsp.index].m_key_image; + pe.block_timestamp = m_transfers[cxt.rsp.index].m_ptx_wallet_info->m_block_timestamp; + pe.stake_unlock_time = tmpl_req.stake_unlock_time = cxt.rsp.stake_unlock_time; + pe.tx_id = tmpl_req.tx_id = m_transfers[cxt.rsp.index].tx_hash(); + pe.tx_out_index = tmpl_req.tx_out_index = m_transfers[cxt.rsp.index].m_internal_output_index; + pe.wallet_index = cxt.rsp.index; + //tmpl_req.pos_index = pe.index; // gindex <--- this should be removed as soon as pos_entry::index is replaced with tx_id and tx_out_index // TODO: also fill out tx_id and tx_out_index for mining tx creation - tmpl_req.extra_text = m_miner_text_info; - tmpl_req.stake_unlock_time = cxt.rsp.stake_unlock_time; //generate packing tx transaction pack_tx = AUTO_VAL_INIT(pack_tx); if (generate_packing_transaction_if_needed(pack_tx, 0)) diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 656439f3..66c31d3c 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -58,7 +58,7 @@ const uint64_t WALLET_MINIMUM_HEIGHT_UNSET_CONST = std::numeric_limits::max(); -const uint64_t WALLET_GLOBAL_OUTPUT_INDEX_UNDEFINED = std::numeric_limits::max(); + #undef LOG_DEFAULT_CHANNEL #define LOG_DEFAULT_CHANNEL "wallet" @@ -1390,8 +1390,8 @@ namespace tools }; do_pos_mining_prepare_entry(cxt, transfer_index); - ctx.total_items_checked++; - ctx.total_amount_checked += tr.amount(); + cxt.total_items_checked++; + cxt.total_amount_checked += tr.amount(); while(step <= ts_window) { //check every WALLET_POS_MINT_CHECK_HEIGHT_INTERVAL seconds wheither top block changed, if so - break the loop diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index bde9d9f4..37fa3957 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -14,6 +14,8 @@ #include "currency_core/bc_escrow_service.h" #include "rpc/core_rpc_server_commands_defs.h" +const uint64_t WALLET_GLOBAL_OUTPUT_INDEX_UNDEFINED = std::numeric_limits::max(); + namespace tools { namespace wallet_public diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 74e99899..12382be3 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -1993,9 +1993,9 @@ void wallets_manager::wallet_vs_options::worker_func() return true; } - uint64_t pos_entries_amount = 0; - for (auto& ent : ctx.sp.pos_entries) - pos_entries_amount += ent.amount; + //uint64_t pos_entries_amount = 0; + //for (auto& ent : ctx.sp.pos_entries) + // pos_entries_amount += ent.amount; w->get()->scan_pos(ctx, break_mining_loop, [this](){ return *plast_daemon_network_state == currency::COMMAND_RPC_GET_INFO::daemon_network_state_online && *plast_daemon_height == last_wallet_synch_height; @@ -2005,7 +2005,7 @@ void wallets_manager::wallet_vs_options::worker_func() { w->get()->build_minted_block(ctx); } - LOG_PRINT_L1(get_log_prefix() << " PoS mining iteration finished, status: " << ctx.rsp.status << ", used " << ctx.sp.pos_entries.size() << " entries with total amount: " << currency::print_money_brief(pos_entries_amount) << ", processed: " << ctx.iterations_processed << " iter."); + LOG_PRINT_L1(get_log_prefix() << " PoS mining iteration finished, status: " << ctx.rsp.status << ", used " << ctx.total_items_checked << " entries with total amount: " << currency::print_money_brief(ctx.total_amount_checked) << ", processed: " << ctx.iterations_processed << " iter."); return true; }); } diff --git a/tests/core_tests/block_reward.cpp b/tests/core_tests/block_reward.cpp index b2d4056a..e47b4bce 100644 --- a/tests/core_tests/block_reward.cpp +++ b/tests/core_tests/block_reward.cpp @@ -63,7 +63,7 @@ bool block_template_against_txs_size::c1(currency::core& c, size_t ev_index, con pos_entry pe = AUTO_VAL_INIT(pe); pe.amount = boost::get(blk_0.miner_tx.vout[0]).amount; pe.block_timestamp = UINT64_MAX; // doesn't matter - pe.index = 0; // global index + pe.g_index = 0; // global index pe.keyimage = ki; pe.wallet_index = UINT64_MAX; // doesn't matter diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp index 20d77516..812ec95b 100644 --- a/tests/core_tests/chaingen.cpp +++ b/tests/core_tests/chaingen.cpp @@ -366,7 +366,7 @@ bool test_generator::sign_block(currency::block& b, bool r = get_output_details_by_global_index(blocks, oi, pe.amount, - pe.index, + pe.g_index, h, pts, out_i, @@ -556,7 +556,7 @@ bool test_generator::find_kernel(const std::list& accs, stake_kernel sk = AUTO_VAL_INIT(sk); build_kernel(pos_entries[i].amount, - pos_entries[i].index, + pos_entries[i].g_index, pos_entries[i].keyimage, sk, blck_chain, @@ -582,7 +582,7 @@ bool test_generator::find_kernel(const std::list& accs, //found kernel LOG_PRINT_GREEN("Found kernel: amount=" << print_money(pos_entries[i].amount) - << ", index=" << pos_entries[i].index + << ", index=" << pos_entries[i].g_index << ", key_image" << pos_entries[i].keyimage << ", diff: " << this_coin_diff, LOG_LEVEL_0); pe = pos_entries[i]; diff --git a/tests/core_tests/chaingen_helpers.h b/tests/core_tests/chaingen_helpers.h index 6b481eb1..44c1ca1d 100644 --- a/tests/core_tests/chaingen_helpers.h +++ b/tests/core_tests/chaingen_helpers.h @@ -175,12 +175,12 @@ inline bool mine_next_pos_block_in_playtime_with_wallet(tools::wallet2& w, const w.fill_mining_context(ctx); if (!ctx.rsp.is_pos_allowed) return false; - - pos_entries_count = ctx.sp.pos_entries.size(); + std::atomic stop(false); w.scan_pos(ctx, stop, [&w](){size_t blocks_fetched; w.refresh(blocks_fetched); return blocks_fetched == 0; }, w.get_core_runtime_config()); + pos_entries_count = ctx.total_items_checked; if (ctx.rsp.status != API_RETURN_CODE_OK) return false;