Monero
node_rpc_proxy.h
Go to the documentation of this file.
1 // Copyright (c) 2017-2018, The Monero Project
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification, are
6 // permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice, this list of
9 // conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 // of conditions and the following disclaimer in the documentation and/or other
13 // materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be
16 // used to endorse or promote products derived from this software without specific
17 // prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 #pragma once
30 
31 #include <string>
32 #include <boost/thread/mutex.hpp>
33 #include "include_base_utils.h"
34 #include "net/http_client.h"
35 
36 namespace tools
37 {
38 
40 {
41 public:
42  NodeRPCProxy(epee::net_utils::http::http_simple_client &http_client, boost::mutex &mutex);
43 
44  void invalidate();
45 
46  boost::optional<std::string> get_rpc_version(uint32_t &version) const;
47  boost::optional<std::string> get_height(uint64_t &height) const;
48  void set_height(uint64_t h);
49  boost::optional<std::string> get_target_height(uint64_t &height) const;
50  boost::optional<std::string> get_block_weight_limit(uint64_t &block_weight_limit) const;
51  boost::optional<std::string> get_earliest_height(uint8_t version, uint64_t &earliest_height) const;
52  boost::optional<std::string> get_dynamic_base_fee_estimate(uint64_t grace_blocks, uint64_t &fee) const;
53  boost::optional<std::string> get_fee_quantization_mask(uint64_t &fee_quantization_mask) const;
54 
55 private:
56  boost::optional<std::string> get_info() const;
57 
58  epee::net_utils::http::http_simple_client &m_http_client;
59  boost::mutex &m_daemon_rpc_mutex;
60 
61  mutable uint64_t m_height;
62  mutable uint64_t m_earliest_height[256];
63  mutable uint64_t m_dynamic_base_fee_estimate;
66  mutable uint64_t m_fee_quantization_mask;
67  mutable uint32_t m_rpc_version;
68  mutable uint64_t m_target_height;
69  mutable uint64_t m_block_weight_limit;
70  mutable time_t m_get_info_time;
71 };
72 
73 }
Definition: node_rpc_proxy.h:39
epee::net_utils::http::http_simple_client & m_http_client
Definition: node_rpc_proxy.h:58
uint64_t height
Definition: blockchain.cpp:88
boost::optional< std::string > get_target_height(uint64_t &height) const
Definition: node_rpc_proxy.cpp:118
boost::optional< std::string > get_dynamic_base_fee_estimate(uint64_t grace_blocks, uint64_t &fee) const
Definition: node_rpc_proxy.cpp:157
boost::optional< std::string > get_info() const
Definition: node_rpc_proxy.cpp:86
uint64_t m_earliest_height[256]
Definition: node_rpc_proxy.h:62
boost::optional< std::string > get_height(uint64_t &height) const
Definition: node_rpc_proxy.cpp:109
uint32_t m_rpc_version
Definition: node_rpc_proxy.h:67
uint64_t m_dynamic_base_fee_estimate_cached_height
Definition: node_rpc_proxy.h:64
uint64_t m_target_height
Definition: node_rpc_proxy.h:68
uint64_t m_fee_quantization_mask
Definition: node_rpc_proxy.h:66
boost::optional< std::string > get_fee_quantization_mask(uint64_t &fee_quantization_mask) const
Definition: node_rpc_proxy.cpp:187
Various Tools.
Definition: apply_permutation.h:39
uint64_t m_dynamic_base_fee_estimate
Definition: node_rpc_proxy.h:63
time_t m_get_info_time
Definition: node_rpc_proxy.h:70
uint8_t version
Definition: blockchain.cpp:87
boost::mutex & m_daemon_rpc_mutex
Definition: node_rpc_proxy.h:59
void invalidate()
Definition: node_rpc_proxy.cpp:48
boost::optional< std::string > get_earliest_height(uint8_t version, uint64_t &earliest_height) const
Definition: node_rpc_proxy.cpp:136
NodeRPCProxy(epee::net_utils::http::http_simple_client &http_client, boost::mutex &mutex)
Definition: node_rpc_proxy.cpp:41
uint64_t m_dynamic_base_fee_estimate_grace_blocks
Definition: node_rpc_proxy.h:65
boost::optional< std::string > get_block_weight_limit(uint64_t &block_weight_limit) const
Definition: node_rpc_proxy.cpp:127
uint64_t m_block_weight_limit
Definition: node_rpc_proxy.h:69
uint64_t m_height
Definition: node_rpc_proxy.h:61
boost::optional< std::string > get_rpc_version(uint32_t &version) const
Definition: node_rpc_proxy.cpp:63
void set_height(uint64_t h)
Definition: node_rpc_proxy.cpp:81