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