mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-12-24 14:17:46 +00:00
Remember RPC version on initial connect
Don't keep asking for it on an intact connection Wallet is too chatty over the wire
This commit is contained in:
parent
51766d026b
commit
dd58057126
2 changed files with 13 additions and 7 deletions
|
@ -1140,7 +1140,8 @@ wallet2::wallet2(network_type nettype, uint64_t kdf_rounds, bool unattended):
|
||||||
m_devices_registered(false),
|
m_devices_registered(false),
|
||||||
m_device_last_key_image_sync(0),
|
m_device_last_key_image_sync(0),
|
||||||
m_use_dns(true),
|
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)
|
if (m_offline)
|
||||||
{
|
{
|
||||||
|
m_rpc_version = 0;
|
||||||
if (version)
|
if (version)
|
||||||
*version = 0;
|
*version = 0;
|
||||||
if (ssl)
|
if (ssl)
|
||||||
|
@ -5166,6 +5168,7 @@ bool wallet2::check_connection(uint32_t *version, bool *ssl, uint32_t timeout)
|
||||||
|
|
||||||
// TODO: Add light wallet version check.
|
// TODO: Add light wallet version check.
|
||||||
if(m_light_wallet) {
|
if(m_light_wallet) {
|
||||||
|
m_rpc_version = 0;
|
||||||
if (version)
|
if (version)
|
||||||
*version = 0;
|
*version = 0;
|
||||||
if (ssl)
|
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);
|
boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex);
|
||||||
if(!m_http_client.is_connected(ssl))
|
if(!m_http_client.is_connected(ssl))
|
||||||
{
|
{
|
||||||
|
m_rpc_version = 0;
|
||||||
m_node_rpc_proxy.invalidate();
|
m_node_rpc_proxy.invalidate();
|
||||||
if (!m_http_client.connect(std::chrono::milliseconds(timeout)))
|
if (!m_http_client.connect(std::chrono::milliseconds(timeout)))
|
||||||
return false;
|
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::request req_t = AUTO_VAL_INIT(req_t);
|
||||||
cryptonote::COMMAND_RPC_GET_VERSION::response resp_t = AUTO_VAL_INIT(resp_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);
|
bool r = invoke_http_json_rpc("/json_rpc", "get_version", req_t, resp_t);
|
||||||
if(!r) {
|
if(!r) {
|
||||||
|
if(version)
|
||||||
*version = 0;
|
*version = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (resp_t.status != CORE_RPC_STATUS_OK)
|
if (resp_t.status == CORE_RPC_STATUS_OK)
|
||||||
*version = 0;
|
m_rpc_version = resp_t.version;
|
||||||
else
|
|
||||||
*version = resp_t.version;
|
|
||||||
}
|
}
|
||||||
|
if (version)
|
||||||
|
*version = m_rpc_version;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1504,6 +1504,7 @@ private:
|
||||||
uint64_t m_device_last_key_image_sync;
|
uint64_t m_device_last_key_image_sync;
|
||||||
bool m_use_dns;
|
bool m_use_dns;
|
||||||
bool m_offline;
|
bool m_offline;
|
||||||
|
uint32_t m_rpc_version;
|
||||||
|
|
||||||
// Aux transaction data from device
|
// Aux transaction data from device
|
||||||
std::unordered_map<crypto::hash, std::string> m_tx_device;
|
std::unordered_map<crypto::hash, std::string> m_tx_device;
|
||||||
|
|
Loading…
Reference in a new issue