From b0a0afc44ca0cbb860e46f714dd9832141caa3ad Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Sat, 7 May 2022 17:39:44 +0800 Subject: [PATCH] fix monerod RPC connectivity issues --- README.md | 2 +- main.cpp | 8 ++++---- src/CmdLineOptions.cpp | 2 +- src/MempoolStatus.cpp | 3 +++ src/page.h | 15 --------------- src/rpccalls.cpp | 4 ++-- src/rpccalls.h | 1 + 7 files changed, 12 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index e842c73..2ebcf29 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,7 @@ xmrblocks, Onion Monero Blockchain Explorer: functionality --ssl-key-file arg path to key file for ssl (https) functionality - -d [ --deamon-url ] arg (=http:://127.0.0.1:18081) + -d [ --deamon-url ] arg (=127.0.0.1:18081) Monero daemon url --daemon-login arg Specify username[:password] for daemon RPC client diff --git a/main.cpp b/main.cpp index fa8e7c8..ffa36b7 100644 --- a/main.cpp +++ b/main.cpp @@ -208,10 +208,10 @@ main(int ac, const char* av[]) string deamon_url {*deamon_url_opt}; - if (testnet && deamon_url == "http:://127.0.0.1:18081") - deamon_url = "http:://127.0.0.1:28081"; - if (stagenet && deamon_url == "http:://127.0.0.1:18081") - deamon_url = "http:://127.0.0.1:38081"; + if (testnet && deamon_url == "127.0.0.1:18081") + deamon_url = "127.0.0.1:28081"; + if (stagenet && deamon_url == "127.0.0.1:18081") + deamon_url = "127.0.0.1:38081"; uint64_t mempool_info_timeout {5000}; diff --git a/src/CmdLineOptions.cpp b/src/CmdLineOptions.cpp index 486c0fc..05c6eef 100644 --- a/src/CmdLineOptions.cpp +++ b/src/CmdLineOptions.cpp @@ -71,7 +71,7 @@ namespace xmreg "path to key file for ssl (https) functionality") ("daemon-login", value(), "Specify username[:password] for daemon RPC client") - ("deamon-url,d", value()->default_value("http:://127.0.0.1:18081"), + ("deamon-url,d", value()->default_value("127.0.0.1:18081"), "Monero daemon url") ("enable-mixin-guess", value()->default_value(false)->implicit_value(true), "enable guessing real outputs in key images based on viewkey"); diff --git a/src/MempoolStatus.cpp b/src/MempoolStatus.cpp index 4309def..a7d609c 100644 --- a/src/MempoolStatus.cpp +++ b/src/MempoolStatus.cpp @@ -227,7 +227,10 @@ MempoolStatus::read_network_info() COMMAND_RPC_GET_INFO::response rpc_network_info; if (!rpc.get_network_info(rpc_network_info)) + { + cerr << "rpc.get_network_info(rpc_network_info) failed"; return false; + } uint64_t fee_estimated; diff --git a/src/page.h b/src/page.h index aa10312..a9121b6 100644 --- a/src/page.h +++ b/src/page.h @@ -578,21 +578,6 @@ page(MicroCore* _mcore, string index2(uint64_t page_no = 0, bool refresh_page = false) { - - // we get network info, such as current hash rate - // but since this makes a rpc call to deamon, we make it as an async - // call. this way we dont have to wait with execution of the rest of the - // index2 method, until deamon gives as the required result. - std::future network_info_ftr = std::async(std::launch::async, [&] - { - json j_info; - - get_monero_network_info(j_info); - - return j_info; - }); - - // get mempool for the front page also using async future std::future mempool_ftr = std::async(std::launch::async, [&] { diff --git a/src/rpccalls.cpp b/src/rpccalls.cpp index f0c3a7a..51277dc 100644 --- a/src/rpccalls.cpp +++ b/src/rpccalls.cpp @@ -21,7 +21,7 @@ rpccalls::rpccalls( timeout_time_ms = std::chrono::milliseconds {timeout_time}; - m_http_client.set_server( + m_http_client.set_server( deamon_url, login, epee::net_utils::ssl_support_t::e_ssl_support_disabled); @@ -183,7 +183,7 @@ rpccalls::get_network_info(COMMAND_RPC_GET_INFO::response& response) { if (resp_t.result.status == CORE_RPC_STATUS_BUSY) { - err = "daemon is busy. Please try again later."; + err = "Daemon is busy. Please try again later."; } else if (resp_t.result.status != CORE_RPC_STATUS_OK) { diff --git a/src/rpccalls.h b/src/rpccalls.h index 17a2d2c..a20285f 100644 --- a/src/rpccalls.h +++ b/src/rpccalls.h @@ -77,6 +77,7 @@ class rpccalls epee::net_utils::http::url_content url; epee::net_utils::http::http_simple_client m_http_client; + std::mutex m_daemon_rpc_mutex; string port;