diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-02-27 17:38:05 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-02-27 17:46:55 +0000 |
commit | b5c74e40416610ad3fdd9047bcffd406ea1067b5 (patch) | |
tree | 7fd9f55019ee6b4a1427037e14c5b566e3359874 /src | |
parent | Merge pull request #1798 (diff) | |
download | monero-b5c74e40416610ad3fdd9047bcffd406ea1067b5.tar.xz |
wallet: invalidate node proxy cache when reconnecting
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/node_rpc_proxy.cpp | 11 | ||||
-rw-r--r-- | src/wallet/node_rpc_proxy.h | 2 | ||||
-rw-r--r-- | src/wallet/wallet2.cpp | 1 |
3 files changed, 14 insertions, 0 deletions
diff --git a/src/wallet/node_rpc_proxy.cpp b/src/wallet/node_rpc_proxy.cpp index cc249b5cc..9c16c7dd2 100644 --- a/src/wallet/node_rpc_proxy.cpp +++ b/src/wallet/node_rpc_proxy.cpp @@ -47,6 +47,17 @@ NodeRPCProxy::NodeRPCProxy(epee::net_utils::http::http_simple_client &http_clien , m_dynamic_per_kb_fee_estimate_grace_blocks(0) {} +void NodeRPCProxy::invalidate() +{ + m_height = 0; + m_height_time = 0; + for (size_t n = 0; n < 256; ++n) + m_earliest_height[n] = 0; + m_dynamic_per_kb_fee_estimate = 0; + m_dynamic_per_kb_fee_estimate_cached_height = 0; + m_dynamic_per_kb_fee_estimate_grace_blocks = 0; +} + boost::optional<std::string> NodeRPCProxy::get_height(uint64_t &height) { const time_t now = time(NULL); diff --git a/src/wallet/node_rpc_proxy.h b/src/wallet/node_rpc_proxy.h index e2f42d541..57cfbbc45 100644 --- a/src/wallet/node_rpc_proxy.h +++ b/src/wallet/node_rpc_proxy.h @@ -41,6 +41,8 @@ class NodeRPCProxy public: NodeRPCProxy(epee::net_utils::http::http_simple_client &http_client, boost::mutex &mutex); + void invalidate(); + boost::optional<std::string> get_height(uint64_t &height); void set_height(uint64_t h); boost::optional<std::string> get_earliest_height(uint8_t version, uint64_t &earliest_height); diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 7b42458c0..14369da3f 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -2286,6 +2286,7 @@ bool wallet2::check_connection(uint32_t *version, uint32_t timeout) if(!m_http_client.is_connected()) { + m_node_rpc_proxy.invalidate(); if (!m_http_client.connect(std::chrono::milliseconds(timeout))) return false; } |