Monero
Loading...
Searching...
No Matches
node_rpc_proxy.h
Go to the documentation of this file.
1// Copyright (c) 2017-2022, 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 <boost/thread/recursive_mutex.hpp>
34#include "include_base_utils.h"
37#include "wallet_rpc_helpers.h"
38
39namespace tools
40{
41
43{
44public:
45 NodeRPCProxy(epee::net_utils::http::abstract_http_client &http_client, rpc_payment_state_t &rpc_payment_state, boost::recursive_mutex &mutex);
46
48 void invalidate();
49 void set_offline(bool offline) { m_offline = offline; }
50
51 boost::optional<std::string> get_rpc_version(uint32_t &rpc_version, std::vector<std::pair<uint8_t, uint64_t>> &daemon_hard_forks, uint64_t &height, uint64_t &target_height);
52 boost::optional<std::string> get_height(uint64_t &height);
53 void set_height(uint64_t h);
54 boost::optional<std::string> get_target_height(uint64_t &height);
55 boost::optional<std::string> get_block_weight_limit(uint64_t &block_weight_limit);
56 boost::optional<std::string> get_adjusted_time(uint64_t &adjusted_time);
57 boost::optional<std::string> get_earliest_height(uint8_t version, uint64_t &earliest_height);
58 boost::optional<std::string> get_dynamic_base_fee_estimate(uint64_t grace_blocks, uint64_t &fee);
59 boost::optional<std::string> get_dynamic_base_fee_estimate_2021_scaling(uint64_t grace_blocks, std::vector<uint64_t> &fees);
60 boost::optional<std::string> get_fee_quantization_mask(uint64_t &fee_quantization_mask);
61 boost::optional<std::string> get_rpc_payment_info(bool mining, bool &payment_required, uint64_t &credits, uint64_t &diff, uint64_t &credits_per_hash_found, cryptonote::blobdata &blob, uint64_t &height, uint64_t &seed_height, crypto::hash &seed_hash, crypto::hash &next_seed_hash, uint32_t &cookie);
62
63private:
64 template<typename T> void handle_payment_changes(const T &res, std::true_type) {
67 if (res.top_hash != m_rpc_payment_state.top_hash)
68 {
71 }
72 }
73 template<typename T> void handle_payment_changes(const T &res, std::false_type) {}
74
75private:
76 boost::optional<std::string> get_info();
77
80 boost::recursive_mutex &m_daemon_rpc_mutex;
83
107 std::vector<std::pair<uint8_t, uint64_t>> m_daemon_hard_forks;
108};
109
110}
static boost::multiprecision::uint128_t fees
Definition: blockchain_stats.cpp:58
static uint64_t h
Definition: blockchain_stats.cpp:55
Definition: abstract_http_client.h:62
Definition: node_rpc_proxy.h:43
std::vector< std::pair< uint8_t, uint64_t > > m_daemon_hard_forks
Definition: node_rpc_proxy.h:107
time_t m_target_height_time
Definition: node_rpc_proxy.h:106
boost::optional< std::string > get_dynamic_base_fee_estimate_2021_scaling(uint64_t grace_blocks, std::vector< uint64_t > &fees)
Definition: node_rpc_proxy.cpp:244
cryptonote::blobdata m_rpc_payment_blob
Definition: node_rpc_proxy.h:99
boost::optional< std::string > get_rpc_payment_info(bool mining, bool &payment_required, uint64_t &credits, uint64_t &diff, uint64_t &credits_per_hash_found, cryptonote::blobdata &blob, uint64_t &height, uint64_t &seed_height, crypto::hash &seed_hash, crypto::hash &next_seed_hash, uint32_t &cookie)
Definition: node_rpc_proxy.cpp:329
void handle_payment_changes(const T &res, std::true_type)
Definition: node_rpc_proxy.h:64
uint64_t m_rpc_payment_credits_per_hash_found
Definition: node_rpc_proxy.h:98
boost::optional< std::string > get_target_height(uint64_t &height)
Definition: node_rpc_proxy.cpp:184
uint64_t m_dynamic_base_fee_estimate_cached_height
Definition: node_rpc_proxy.h:87
uint64_t m_target_height
Definition: node_rpc_proxy.h:93
uint32_t m_rpc_version
Definition: node_rpc_proxy.h:92
crypto::hash m_rpc_payment_next_seed_hash
Definition: node_rpc_proxy.h:103
epee::net_utils::http::abstract_http_client & m_http_client
Definition: node_rpc_proxy.h:78
void set_height(uint64_t h)
Definition: node_rpc_proxy.cpp:132
boost::recursive_mutex & m_daemon_rpc_mutex
Definition: node_rpc_proxy.h:80
std::vector< uint64_t > m_dynamic_base_fee_estimate_vector
Definition: node_rpc_proxy.h:89
boost::optional< std::string > get_fee_quantization_mask(uint64_t &fee_quantization_mask)
Definition: node_rpc_proxy.cpp:290
uint64_t m_rpc_payment_height
Definition: node_rpc_proxy.h:100
uint64_t m_dynamic_base_fee_estimate
Definition: node_rpc_proxy.h:86
boost::optional< std::string > get_adjusted_time(uint64_t &adjusted_time)
Definition: node_rpc_proxy.cpp:209
boost::optional< std::string > get_dynamic_base_fee_estimate(uint64_t grace_blocks, uint64_t &fee)
Definition: node_rpc_proxy.cpp:280
uint64_t m_fee_quantization_mask
Definition: node_rpc_proxy.h:90
bool m_offline
Definition: node_rpc_proxy.h:82
uint64_t m_block_weight_limit
Definition: node_rpc_proxy.h:94
boost::optional< std::string > get_height(uint64_t &height)
Definition: node_rpc_proxy.cpp:168
void invalidate()
Definition: node_rpc_proxy.cpp:65
void set_client_secret_key(const crypto::secret_key &skey)
Definition: node_rpc_proxy.h:47
void handle_payment_changes(const T &res, std::false_type)
Definition: node_rpc_proxy.h:73
boost::optional< std::string > get_earliest_height(uint8_t version, uint64_t &earliest_height)
Definition: node_rpc_proxy.cpp:218
crypto::secret_key m_client_id_secret_key
Definition: node_rpc_proxy.h:81
uint64_t m_rpc_payment_seed_height
Definition: node_rpc_proxy.h:101
time_t m_height_time
Definition: node_rpc_proxy.h:105
boost::optional< std::string > get_rpc_version(uint32_t &rpc_version, std::vector< std::pair< uint8_t, uint64_t > > &daemon_hard_forks, uint64_t &height, uint64_t &target_height)
Definition: node_rpc_proxy.cpp:93
uint64_t m_earliest_height[256]
Definition: node_rpc_proxy.h:85
rpc_payment_state_t & m_rpc_payment_state
Definition: node_rpc_proxy.h:79
uint64_t m_rpc_payment_diff
Definition: node_rpc_proxy.h:97
time_t m_get_info_time
Definition: node_rpc_proxy.h:95
void set_offline(bool offline)
Definition: node_rpc_proxy.h:49
boost::optional< std::string > get_info()
Definition: node_rpc_proxy.cpp:138
time_t m_rpc_payment_info_time
Definition: node_rpc_proxy.h:96
crypto::hash m_rpc_payment_seed_hash
Definition: node_rpc_proxy.h:102
uint64_t m_adjusted_time
Definition: node_rpc_proxy.h:91
uint64_t m_dynamic_base_fee_estimate_grace_blocks
Definition: node_rpc_proxy.h:88
boost::optional< std::string > get_block_weight_limit(uint64_t &block_weight_limit)
Definition: node_rpc_proxy.cpp:200
uint64_t m_height
Definition: node_rpc_proxy.h:84
uint32_t m_rpc_payment_cookie
Definition: node_rpc_proxy.h:104
#define CORE_RPC_STATUS_PAYMENT_REQUIRED
Definition: core_rpc_server_commands_defs.h:81
#define CORE_RPC_STATUS_OK
Definition: core_rpc_server_commands_defs.h:78
const char * res
Definition: hmac_keccak.cpp:42
static int version
Definition: mdb_load.c:29
POD_CLASS hash
Definition: hash.h:48
std::string blobdata
Definition: blobdatatype.h:39
Definition: mining.py:1
Various Tools.
Definition: apply_permutation.h:40
unsigned int uint32_t
Definition: stdint.h:126
unsigned char uint8_t
Definition: stdint.h:124
unsigned __int64 uint64_t
Definition: stdint.h:136
Definition: wallet_rpc_helpers.h:50
std::string top_hash
Definition: wallet_rpc_helpers.h:54
uint64_t credits
Definition: wallet_rpc_helpers.h:51
bool stale
Definition: wallet_rpc_helpers.h:55
#define T(x)