diff options
Diffstat (limited to 'src/wallet/node_rpc_proxy.cpp')
-rw-r--r-- | src/wallet/node_rpc_proxy.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/wallet/node_rpc_proxy.cpp b/src/wallet/node_rpc_proxy.cpp index f5f3c0e1b..1d5078a11 100644 --- a/src/wallet/node_rpc_proxy.cpp +++ b/src/wallet/node_rpc_proxy.cpp @@ -37,9 +37,10 @@ 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::recursive_mutex &mutex) : m_http_client(http_client) , m_daemon_rpc_mutex(mutex) + , m_offline(false) { invalidate(); } @@ -61,6 +62,8 @@ void NodeRPCProxy::invalidate() boost::optional<std::string> NodeRPCProxy::get_rpc_version(uint32_t &rpc_version) const { + if (m_offline) + return boost::optional<std::string>("offline"); if (m_rpc_version == 0) { cryptonote::COMMAND_RPC_GET_VERSION::request req_t = AUTO_VAL_INIT(req_t); @@ -84,6 +87,8 @@ void NodeRPCProxy::set_height(uint64_t h) boost::optional<std::string> NodeRPCProxy::get_info() const { + if (m_offline) + return boost::optional<std::string>("offline"); const time_t now = time(NULL); if (now >= m_get_info_time + 30) // re-cache every 30 seconds { @@ -134,6 +139,8 @@ boost::optional<std::string> NodeRPCProxy::get_block_weight_limit(uint64_t &bloc boost::optional<std::string> NodeRPCProxy::get_earliest_height(uint8_t version, uint64_t &earliest_height) const { + if (m_offline) + return boost::optional<std::string>("offline"); if (m_earliest_height[version] == 0) { cryptonote::COMMAND_RPC_HARD_FORK_INFO::request req_t = AUTO_VAL_INIT(req_t); @@ -161,6 +168,8 @@ boost::optional<std::string> NodeRPCProxy::get_dynamic_base_fee_estimate(uint64_ if (result) return result; + if (m_offline) + return boost::optional<std::string>("offline"); if (m_dynamic_base_fee_estimate_cached_height != height || m_dynamic_base_fee_estimate_grace_blocks != grace_blocks) { cryptonote::COMMAND_RPC_GET_BASE_FEE_ESTIMATE::request req_t = AUTO_VAL_INIT(req_t); @@ -191,6 +200,8 @@ boost::optional<std::string> NodeRPCProxy::get_fee_quantization_mask(uint64_t &f if (result) return result; + if (m_offline) + return boost::optional<std::string>("offline"); if (m_dynamic_base_fee_estimate_cached_height != height) { cryptonote::COMMAND_RPC_GET_BASE_FEE_ESTIMATE::request req_t = AUTO_VAL_INIT(req_t); |