diff options
author | luigi1111 <luigi1111w@gmail.com> | 2019-07-24 14:29:10 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2019-07-24 14:29:10 -0500 |
commit | c4071a00fb142f9824a1faca9e172287463b173f (patch) | |
tree | d232625ff30025f20ba08744c977f74d6dd47888 /src | |
parent | Merge pull request #5597 (diff) | |
parent | Remember RPC version on initial connect (diff) | |
download | monero-c4071a00fb142f9824a1faca9e172287463b173f.tar.xz |
Merge pull request #5600
dd58057 Remember RPC version on initial connect (hyc)
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/wallet2.cpp | 19 | ||||
-rw-r--r-- | src/wallet/wallet2.h | 1 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index e352917dd..f25e9ad97 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1140,7 +1140,8 @@ wallet2::wallet2(network_type nettype, uint64_t kdf_rounds, bool unattended): m_devices_registered(false), m_device_last_key_image_sync(0), m_use_dns(true), - m_offline(false) + m_offline(false), + m_rpc_version(0) { } @@ -5157,6 +5158,7 @@ bool wallet2::check_connection(uint32_t *version, bool *ssl, uint32_t timeout) if (m_offline) { + m_rpc_version = 0; if (version) *version = 0; if (ssl) @@ -5166,6 +5168,7 @@ bool wallet2::check_connection(uint32_t *version, bool *ssl, uint32_t timeout) // TODO: Add light wallet version check. if(m_light_wallet) { + m_rpc_version = 0; if (version) *version = 0; if (ssl) @@ -5177,6 +5180,7 @@ bool wallet2::check_connection(uint32_t *version, bool *ssl, uint32_t timeout) boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex); if(!m_http_client.is_connected(ssl)) { + m_rpc_version = 0; m_node_rpc_proxy.invalidate(); if (!m_http_client.connect(std::chrono::milliseconds(timeout))) return false; @@ -5185,20 +5189,21 @@ bool wallet2::check_connection(uint32_t *version, bool *ssl, uint32_t timeout) } } - if (version) + if (!m_rpc_version) { cryptonote::COMMAND_RPC_GET_VERSION::request req_t = AUTO_VAL_INIT(req_t); cryptonote::COMMAND_RPC_GET_VERSION::response resp_t = AUTO_VAL_INIT(resp_t); bool r = invoke_http_json_rpc("/json_rpc", "get_version", req_t, resp_t); if(!r) { - *version = 0; + if(version) + *version = 0; return false; } - if (resp_t.status != CORE_RPC_STATUS_OK) - *version = 0; - else - *version = resp_t.version; + if (resp_t.status == CORE_RPC_STATUS_OK) + m_rpc_version = resp_t.version; } + if (version) + *version = m_rpc_version; return true; } diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 43fa8cb6d..a6d042297 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -1506,6 +1506,7 @@ private: uint64_t m_device_last_key_image_sync; bool m_use_dns; bool m_offline; + uint32_t m_rpc_version; // Aux transaction data from device std::unordered_map<crypto::hash, std::string> m_tx_device; |