Merge pull request #1889

24ae7140 wallet: increase node_rpc_proxy timeout to match wallet2 (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2017-03-19 22:55:10 +02:00
commit 4a6fc007c6
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD

View file

@ -36,6 +36,8 @@ using namespace epee;
namespace tools namespace tools
{ {
static const std::chrono::seconds rpc_timeout = std::chrono::minutes(3) + std::chrono::seconds(30);
NodeRPCProxy::NodeRPCProxy(epee::net_utils::http::http_simple_client &http_client, boost::mutex &mutex) NodeRPCProxy::NodeRPCProxy(epee::net_utils::http::http_simple_client &http_client, boost::mutex &mutex)
: m_http_client(http_client) : m_http_client(http_client)
, m_daemon_rpc_mutex(mutex) , m_daemon_rpc_mutex(mutex)
@ -71,7 +73,7 @@ boost::optional<std::string> NodeRPCProxy::get_rpc_version(uint32_t &rpc_version
req_t.id = epee::serialization::storage_entry(0); req_t.id = epee::serialization::storage_entry(0);
req_t.method = "get_version"; req_t.method = "get_version";
m_daemon_rpc_mutex.lock(); m_daemon_rpc_mutex.lock();
bool r = net_utils::invoke_http_json("/json_rpc", req_t, resp_t, m_http_client); bool r = net_utils::invoke_http_json("/json_rpc", req_t, resp_t, m_http_client, rpc_timeout);
m_daemon_rpc_mutex.unlock(); m_daemon_rpc_mutex.unlock();
CHECK_AND_ASSERT_MES(r, std::string(), "Failed to connect to daemon"); CHECK_AND_ASSERT_MES(r, std::string(), "Failed to connect to daemon");
CHECK_AND_ASSERT_MES(resp_t.result.status != CORE_RPC_STATUS_BUSY, resp_t.result.status, "Failed to connect to daemon"); CHECK_AND_ASSERT_MES(resp_t.result.status != CORE_RPC_STATUS_BUSY, resp_t.result.status, "Failed to connect to daemon");
@ -91,7 +93,7 @@ boost::optional<std::string> NodeRPCProxy::get_height(uint64_t &height)
cryptonote::COMMAND_RPC_GET_HEIGHT::response res = AUTO_VAL_INIT(res); cryptonote::COMMAND_RPC_GET_HEIGHT::response res = AUTO_VAL_INIT(res);
m_daemon_rpc_mutex.lock(); m_daemon_rpc_mutex.lock();
bool r = net_utils::invoke_http_json("/getheight", req, res, m_http_client); bool r = net_utils::invoke_http_json("/getheight", req, res, m_http_client, rpc_timeout);
m_daemon_rpc_mutex.unlock(); m_daemon_rpc_mutex.unlock();
CHECK_AND_ASSERT_MES(r, std::string(), "Failed to connect to daemon"); CHECK_AND_ASSERT_MES(r, std::string(), "Failed to connect to daemon");
CHECK_AND_ASSERT_MES(res.status != CORE_RPC_STATUS_BUSY, res.status, "Failed to connect to daemon"); CHECK_AND_ASSERT_MES(res.status != CORE_RPC_STATUS_BUSY, res.status, "Failed to connect to daemon");
@ -120,7 +122,7 @@ boost::optional<std::string> NodeRPCProxy::get_earliest_height(uint8_t version,
req_t.id = epee::serialization::storage_entry(0); req_t.id = epee::serialization::storage_entry(0);
req_t.method = "hard_fork_info"; req_t.method = "hard_fork_info";
req_t.params.version = version; req_t.params.version = version;
bool r = net_utils::invoke_http_json("/json_rpc", req_t, resp_t, m_http_client); bool r = net_utils::invoke_http_json("/json_rpc", req_t, resp_t, m_http_client, rpc_timeout);
m_daemon_rpc_mutex.unlock(); m_daemon_rpc_mutex.unlock();
CHECK_AND_ASSERT_MES(r, std::string(), "Failed to connect to daemon"); CHECK_AND_ASSERT_MES(r, std::string(), "Failed to connect to daemon");
CHECK_AND_ASSERT_MES(resp_t.result.status != CORE_RPC_STATUS_BUSY, resp_t.result.status, "Failed to connect to daemon"); CHECK_AND_ASSERT_MES(resp_t.result.status != CORE_RPC_STATUS_BUSY, resp_t.result.status, "Failed to connect to daemon");
@ -150,7 +152,7 @@ boost::optional<std::string> NodeRPCProxy::get_dynamic_per_kb_fee_estimate(uint6
req_t.id = epee::serialization::storage_entry(0); req_t.id = epee::serialization::storage_entry(0);
req_t.method = "get_fee_estimate"; req_t.method = "get_fee_estimate";
req_t.params.grace_blocks = grace_blocks; req_t.params.grace_blocks = grace_blocks;
bool r = net_utils::invoke_http_json("/json_rpc", req_t, resp_t, m_http_client); bool r = net_utils::invoke_http_json("/json_rpc", req_t, resp_t, m_http_client, rpc_timeout);
m_daemon_rpc_mutex.unlock(); m_daemon_rpc_mutex.unlock();
CHECK_AND_ASSERT_MES(r, std::string(), "Failed to connect to daemon"); CHECK_AND_ASSERT_MES(r, std::string(), "Failed to connect to daemon");
CHECK_AND_ASSERT_MES(resp_t.result.status != CORE_RPC_STATUS_BUSY, resp_t.result.status, "Failed to connect to daemon"); CHECK_AND_ASSERT_MES(resp_t.result.status != CORE_RPC_STATUS_BUSY, resp_t.result.status, "Failed to connect to daemon");