moneroexamples 7 years ago
parent f9b8089168
commit d01f760404

@ -211,9 +211,7 @@ MempoolStatus::read_network_info()
COMMAND_RPC_GET_INFO::response rpc_network_info;
if (!rpc.get_network_info(rpc_network_info))
{
return false;
}
uint64_t fee_estimated;
@ -229,6 +227,11 @@ MempoolStatus::read_network_info()
(void) error_msg;
COMMAND_RPC_HARD_FORK_INFO::response rpc_hardfork_info;
if (!rpc.get_hardfork_info(rpc_hardfork_info))
return false;
network_info local_copy;
@ -254,7 +257,7 @@ MempoolStatus::read_network_info()
local_copy.fee_per_kb = fee_estimated;
local_copy.info_timestamp = static_cast<uint64_t>(std::time(nullptr));
local_copy.current_hf_version = core_storage->get_current_hard_fork_version();
local_copy.current_hf_version = rpc_hardfork_info.version;
local_copy.current = true;

@ -207,6 +207,68 @@ rpccalls::get_network_info(COMMAND_RPC_GET_INFO::response& response)
}
bool
rpccalls::get_hardfork_info(COMMAND_RPC_HARD_FORK_INFO::response& response)
{
epee::json_rpc::request<cryptonote::COMMAND_RPC_HARD_FORK_INFO::request> req_t = AUTO_VAL_INIT(req_t);
epee::json_rpc::response<cryptonote::COMMAND_RPC_HARD_FORK_INFO::response, std::string> resp_t = AUTO_VAL_INIT(resp_t);
bool r {false};
req_t.jsonrpc = "2.0";
req_t.id = epee::serialization::storage_entry(0);
req_t.method = "hard_fork_info";
{
std::lock_guard<std::mutex> guard(m_daemon_rpc_mutex);
if (!connect_to_monero_deamon())
{
cerr << "get_hardfork_info: not connected to deamon" << endl;
return false;
}
r = epee::net_utils::invoke_http_json("/json_rpc",
req_t, resp_t,
m_http_client);
}
string err;
if (r)
{
if (resp_t.result.status == CORE_RPC_STATUS_BUSY)
{
err = "daemon is busy. Please try again later.";
}
else if (resp_t.result.status != CORE_RPC_STATUS_OK)
{
err = resp_t.result.status;
}
if (!err.empty())
{
cerr << "Error connecting to Monero deamon due to "
<< err << endl;
return false;
}
}
else
{
cerr << "Error connecting to Monero deamon at "
<< deamon_url << endl;
return false;
}
response = resp_t.result;
return true;
}
bool
rpccalls::get_dynamic_per_kb_fee_estimate(
uint64_t grace_blocks,

@ -99,6 +99,9 @@ public:
bool
get_network_info(COMMAND_RPC_GET_INFO::response& info);
bool
get_hardfork_info( COMMAND_RPC_HARD_FORK_INFO::response& res);
bool
get_dynamic_per_kb_fee_estimate(
uint64_t grace_blocks,

Loading…
Cancel
Save