added wallet_transfer_info to transfer() RPC
This commit is contained in:
parent
e66b21085b
commit
686c137332
6 changed files with 65 additions and 6 deletions
|
|
@ -100,7 +100,7 @@ namespace utils
|
|||
{
|
||||
return cnt == cntr.size();
|
||||
});
|
||||
LOG_PRINT_L0("All jobs finiahed");
|
||||
//LOG_PRINT_L0("All jobs finiahed");
|
||||
}
|
||||
|
||||
~threads_pool()
|
||||
|
|
|
|||
|
|
@ -5341,6 +5341,15 @@ bool wallet2::build_minted_block(const mining_context& cxt, const currency::acco
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::find_unconfirmed_tx(const crypto::hash& tx_id, wallet_public::wallet_transfer_info& res) const
|
||||
{
|
||||
auto it = m_unconfirmed_txs.find(tx_id);
|
||||
if (it == m_unconfirmed_txs.end())
|
||||
return false;
|
||||
res = it->second;
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void wallet2::get_unconfirmed_transfers(std::vector<wallet_public::wallet_transfer_info>& trs, bool exclude_mining_txs)
|
||||
{
|
||||
for (auto& u : m_unconfirmed_txs)
|
||||
|
|
|
|||
|
|
@ -769,7 +769,7 @@ namespace tools
|
|||
void set_concise_mode(bool enabled) { m_concise_mode = enabled; }
|
||||
void set_concise_mode_reorg_max_reorg_blocks(uint64_t max_blocks) { m_wallet_concise_mode_max_reorg_blocks = max_blocks; }
|
||||
void set_concise_mode_truncate_history(uint64_t max_entries) { m_truncate_history_max_entries = max_entries; }
|
||||
|
||||
bool find_unconfirmed_tx(const crypto::hash& tx_id, wallet_public::wallet_transfer_info& res) const;
|
||||
|
||||
construct_tx_param get_default_construct_tx_param();
|
||||
|
||||
|
|
|
|||
|
|
@ -722,11 +722,13 @@ namespace wallet_public
|
|||
std::string tx_hash;
|
||||
std::string tx_unsigned_hex; // for cold-signing process
|
||||
uint64_t tx_size;
|
||||
std::optional<wallet_transfer_info> tx_details;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(tx_hash) DOC_DSCR("Has of the generated transaction(if succeded)") DOC_EXMP("01220e8304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a93") DOC_END
|
||||
KV_SERIALIZE(tx_unsigned_hex)
|
||||
KV_SERIALIZE(tx_unsigned_hex) DOC_DSCR("Has unsigned tx blob in hex encoding") DOC_EXMP("e383d55ca5887b34f158a7365bbcd01220e8304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a9301220e8304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a9301220e8304d46b940a86e383d55ca5887b34f158a7365bbcdd17c5a305814a93") DOC_END
|
||||
KV_SERIALIZE(tx_size) DOC_DSCR("Transaction size in bytes") DOC_EXMP(1234) DOC_END
|
||||
KV_SERIALIZE(tx_details) DOC_DSCR("Tx details[optional]") DOC_EXMP_AGGR() DOC_END
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -554,8 +554,15 @@ namespace tools
|
|||
}
|
||||
else
|
||||
{
|
||||
res.tx_hash = epee::string_tools::pod_to_hex(currency::get_transaction_hash(result.tx));
|
||||
crypto::hash tx_id = currency::get_transaction_hash(result.tx);
|
||||
res.tx_hash = epee::string_tools::pod_to_hex(tx_id);
|
||||
res.tx_size = get_object_blobsize(result.tx);
|
||||
//try to get wallet_transfer_info
|
||||
wallet_public::wallet_transfer_info wti = AUTO_VAL_INIT(wti);
|
||||
if (w.get_wallet()->find_unconfirmed_tx(tx_id, wti))
|
||||
{
|
||||
res.tx_details = wti;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "wallet/plain_wallet_api.h"
|
||||
#include "wallet/view_iface.h"
|
||||
#include "wallet/plain_wallet_api_defs.h"
|
||||
#include "math_helper.h"
|
||||
|
||||
PUSH_VS_WARNINGS
|
||||
DISABLE_VS_WARNINGS(4244)
|
||||
|
|
@ -184,17 +185,57 @@ void test_plain_wallet()
|
|||
|
||||
}
|
||||
|
||||
void multithread_test_of_get_coinbase_hash_cached()
|
||||
{
|
||||
epee::math_helper::once_a_time_seconds<1> print_interwal;
|
||||
|
||||
try
|
||||
{
|
||||
crypto::hash h = currency::null_hash;
|
||||
utils::threads_pool pool;
|
||||
pool.init();
|
||||
for (uint64_t j = 0; j != 100000000; j++)
|
||||
{
|
||||
|
||||
print_interwal.do_call([&]() { LOG_PRINT_L0("Job " << j << " started, h=" << h); return true; });
|
||||
currency::block_extended_info bei = AUTO_VAL_INIT(bei);
|
||||
utils::threads_pool::jobs_container jobs;
|
||||
size_t i = 0;
|
||||
|
||||
for (; i != 10; i++)
|
||||
{
|
||||
utils::threads_pool::add_job_to_container(jobs, [&, i]() {
|
||||
h = get_coinbase_hash_cached(bei);
|
||||
//LOG_PRINT_L0("Job " << i << " started");
|
||||
//epee::misc_utils::sleep_no_w(10000);
|
||||
// ++count_jobs_finished; LOG_PRINT_L0("Job " << i << " finished");
|
||||
});
|
||||
}
|
||||
|
||||
pool.add_batch_and_wait(jobs);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
LOG_ERROR("Exception happened");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
epee::string_tools::set_module_name_and_folder(argv[0]);
|
||||
epee::log_space::get_set_log_detalisation_level(true, LOG_LEVEL_2);
|
||||
//epee::log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL, LOG_LEVEL_2);
|
||||
epee::log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL, LOG_LEVEL_2);
|
||||
//epee::log_space::log_singletone::add_logger(LOGGER_FILE,
|
||||
// epee::log_space::log_singletone::get_default_log_file().c_str(),
|
||||
// epee::log_space::log_singletone::get_default_log_folder().c_str());
|
||||
|
||||
test_tx_json_serialization();
|
||||
multithread_test_of_get_coinbase_hash_cached();
|
||||
//test_tx_json_serialization();
|
||||
//test_base64_serialization();
|
||||
//test_plain_wallet();
|
||||
//parse_weird_tx();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue