1
0
Fork 0
forked from lthn/blockchain

more profiling logs + callback for the native lib

This commit is contained in:
cryptozoidberg 2025-03-09 14:59:21 +04:00
parent 09ddda7dba
commit 6b152827af
No known key found for this signature in database
GPG key ID: 2E10CC61CAC8F36D
5 changed files with 39 additions and 13 deletions

View file

@ -311,7 +311,7 @@ namespace currency
bool core_rpc_server::on_get_blocks(const COMMAND_RPC_GET_BLOCKS_FAST::request& req, COMMAND_RPC_GET_BLOCKS_FAST::response& res, connection_context& cntx)
{
CHECK_CORE_READY();
LOG_PRINT_L2("[on_get_blocks]: Prevalidating....");
if (req.block_ids.back() != m_core.get_blockchain_storage().get_block_id_by_height(0))
{
//genesis mismatch, return specific
@ -325,7 +325,7 @@ namespace currency
res.status = API_RETURN_CODE_BAD_ARG;
return true;
}
LOG_PRINT_L2("[on_get_blocks]: find_blockchain_supplement ....");
blockchain_storage::blocks_direct_container bs;
if (!m_core.get_blockchain_storage().find_blockchain_supplement(req.block_ids, bs, res.current_height, res.start_height, COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT, req.minimum_height))
{
@ -333,6 +333,7 @@ namespace currency
return false;
}
LOG_PRINT_L2("[on_get_blocks]: Enumerating over blocks ....");
for (auto& b : bs)
{
res.blocks.resize(res.blocks.size()+1);
@ -349,7 +350,7 @@ namespace currency
i++;
}
}
LOG_PRINT_L2("[on_get_blocks]: Finished");
res.status = API_RETURN_CODE_OK;
return true;
}

View file

@ -69,6 +69,7 @@ namespace plain_wallet
std::atomic<bool> initialized = false;
std::atomic<bool> postponed_run_wallet = false;
std::atomic<bool> postponed_main_worked_started = false;
callback_type m_callback = nullptr;
std::atomic<uint64_t> gjobs_counter;
std::map<uint64_t, std::string> gjobs;
@ -555,11 +556,28 @@ namespace plain_wallet
{
return;
}
CRITICAL_REGION_LOCAL(inst_ptr->gjobs_lock);
inst_ptr->gjobs[job_id] = res;
LOG_PRINT_L2("[ASYNC_CALL]: Finished(result put), job id: " << job_id);
if (inst_ptr->m_callback)
{
inst_ptr->m_callback(job_id, res);
LOG_PRINT_L2("[ASYNC_CALL]: Finished(result caalback), job id: " << job_id);
}
else
{
CRITICAL_REGION_LOCAL(inst_ptr->gjobs_lock);
inst_ptr->gjobs[job_id] = res;
LOG_PRINT_L2("[ASYNC_CALL]: Finished(result put), job id: " << job_id);
}
}
void set_callback(callback_type callback)
{
auto inst_ptr = std::atomic_load(&ginstance_ptr);
if (!inst_ptr)
{
return;
}
inst_ptr->m_callback = callback;
}
std::string async_call(const std::string& method_name, uint64_t instance_id, const std::string& params)
{

View file

@ -47,6 +47,10 @@ namespace plain_wallet
std::string get_wallet_info(hwallet h);
std::string reset_wallet_password(hwallet h, const std::string& password);
uint64_t get_current_tx_fee(uint64_t priority); // 0 (default), 1 (unimportant), 2 (normal), 3 (elevated), 4 (priority)
typedef void (*callback_type)(uint64_t job_id, const std::string& job_response);
void set_callback(callback_type callback);
}

View file

@ -37,12 +37,12 @@ void test_plain_wallet()
{
//std::string res = plain_wallet::init("195.201.107.230", "33340", "C:\\Users\\roky\\home\\", 0);
//std::string res = plain_wallet::init("", "", "C:\\Users\\roky\\home\\", 0);
std::string res = plain_wallet::init("http://zano.api.puffin.systems", "80", "C:\\Users\\roky\\home\\", 0);
std::string res = plain_wallet::init("http://127.0.0.1:11211", "C:\\Users\\roky\\home\\", 0);
//std::string res = plain_wallet::init("127.0.0.1", "12111", "C:\\Users\\roky\\home22\\", 0);
plain_wallet::configure_object conf = AUTO_VAL_INIT(conf);
//plain_wallet::configure_response conf_resp = AUTO_VAL_INIT(conf_resp);
conf.postponed_run_wallet = true;
//conf.postponed_run_wallet = true;
std::string r = plain_wallet::sync_call("configure", 0, epee::serialization::store_t_to_json(conf));
@ -58,7 +58,10 @@ void test_plain_wallet()
//res = plain_wallet::sync_call("reset_connection_url", 0, "195.201.107.230:33336");
//res = plain_wallet::sync_call("reset_connection_url", 0, "https://node.zano.org:443");
res = plain_wallet::sync_call("reset_connection_url", 0, "https://zano.cakewallet.com");
//res = plain_wallet::sync_call("reset_connection_url", 0, "https://zano.cakewallet.com");
//res = plain_wallet::sync_call("reset_connection_url", 0, "https://zano.api.wombat.systems:443");
//res = plain_wallet::sync_call("reset_connection_url", 0, "http://127.0.0.1:11211");
r = plain_wallet::sync_call("run_wallet", instance_id, "");

View file

@ -1,11 +1,11 @@
{
"maj":1,
"min":0,
"maj":2,
"min":1,
"rev":0,
"build":40,
"build":382,
"cs":[
{
"build":40,
"build":382,
"mode":3
}
]