wallet: invalidate node proxy cache when reconnecting

This commit is contained in:
moneromooo-monero 2017-02-27 17:38:05 +00:00
parent beee286c7b
commit b5c74e4041
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
3 changed files with 14 additions and 0 deletions

View file

@ -47,6 +47,17 @@ NodeRPCProxy::NodeRPCProxy(epee::net_utils::http::http_simple_client &http_clien
, m_dynamic_per_kb_fee_estimate_grace_blocks(0) , 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) boost::optional<std::string> NodeRPCProxy::get_height(uint64_t &height)
{ {
const time_t now = time(NULL); const time_t now = time(NULL);

View file

@ -41,6 +41,8 @@ class NodeRPCProxy
public: public:
NodeRPCProxy(epee::net_utils::http::http_simple_client &http_client, boost::mutex &mutex); NodeRPCProxy(epee::net_utils::http::http_simple_client &http_client, boost::mutex &mutex);
void invalidate();
boost::optional<std::string> get_height(uint64_t &height); boost::optional<std::string> get_height(uint64_t &height);
void set_height(uint64_t h); void set_height(uint64_t h);
boost::optional<std::string> get_earliest_height(uint8_t version, uint64_t &earliest_height); boost::optional<std::string> get_earliest_height(uint8_t version, uint64_t &earliest_height);

View file

@ -2286,6 +2286,7 @@ bool wallet2::check_connection(uint32_t *version, uint32_t timeout)
if(!m_http_client.is_connected()) if(!m_http_client.is_connected())
{ {
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;
} }