39 static const std::chrono::seconds rpc_timeout = std::chrono::minutes(3) + std::chrono::seconds(30);
42 : m_http_client(http_client)
43 , m_daemon_rpc_mutex(mutex)
52 for (
size_t n = 0; n < 256; ++n)
53 m_earliest_height[n] = 0;
54 m_dynamic_base_fee_estimate = 0;
55 m_dynamic_base_fee_estimate_cached_height = 0;
56 m_dynamic_base_fee_estimate_grace_blocks = 0;
57 m_fee_quantization_mask = 1;
60 m_block_weight_limit = 0;
67 return boost::optional<std::string>(
"offline");
68 if (m_rpc_version == 0)
72 m_daemon_rpc_mutex.lock();
74 m_daemon_rpc_mutex.unlock();
78 m_rpc_version = resp_t.version;
80 rpc_version = m_rpc_version;
81 return boost::optional<std::string>();
89 boost::optional<std::string> NodeRPCProxy::get_info()
const 92 return boost::optional<std::string>(
"offline");
93 const time_t now =
time(NULL);
94 if (now >= m_get_info_time + 30)
99 m_daemon_rpc_mutex.lock();
101 m_daemon_rpc_mutex.unlock();
106 m_height = resp_t.height;
107 m_target_height = resp_t.target_height;
108 m_block_weight_limit = resp_t.block_weight_limit ? resp_t.block_weight_limit : resp_t.block_size_limit;
109 m_get_info_time = now;
111 return boost::optional<std::string>();
116 auto res = get_info();
120 return boost::optional<std::string>();
125 auto res = get_info();
129 return boost::optional<std::string>();
134 auto res = get_info();
137 block_weight_limit = m_block_weight_limit;
138 return boost::optional<std::string>();
144 return boost::optional<std::string>(
"offline");
145 if (m_earliest_height[
version] == 0)
150 m_daemon_rpc_mutex.lock();
153 m_daemon_rpc_mutex.unlock();
157 m_earliest_height[
version] = resp_t.earliest_height;
160 earliest_height = m_earliest_height[
version];
161 return boost::optional<std::string>();
173 return boost::optional<std::string>(
"offline");
174 if (m_dynamic_base_fee_estimate_cached_height !=
height || m_dynamic_base_fee_estimate_grace_blocks != grace_blocks)
179 m_daemon_rpc_mutex.lock();
180 req_t.grace_blocks = grace_blocks;
182 m_daemon_rpc_mutex.unlock();
186 m_dynamic_base_fee_estimate = resp_t.fee;
187 m_dynamic_base_fee_estimate_cached_height =
height;
188 m_dynamic_base_fee_estimate_grace_blocks = grace_blocks;
189 m_fee_quantization_mask = resp_t.quantization_mask;
192 fee = m_dynamic_base_fee_estimate;
193 return boost::optional<std::string>();
205 return boost::optional<std::string>(
"offline");
206 if (m_dynamic_base_fee_estimate_cached_height !=
height)
211 m_daemon_rpc_mutex.lock();
212 req_t.grace_blocks = m_dynamic_base_fee_estimate_grace_blocks;
214 m_daemon_rpc_mutex.unlock();
218 m_dynamic_base_fee_estimate = resp_t.fee;
219 m_dynamic_base_fee_estimate_cached_height =
height;
220 m_fee_quantization_mask = resp_t.quantization_mask;
223 fee_quantization_mask = m_fee_quantization_mask;
224 if (fee_quantization_mask == 0)
226 MERROR(
"Fee quantization mask is 0, forcing to 1");
227 fee_quantization_mask = 1;
229 return boost::optional<std::string>();
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
#define CORE_RPC_STATUS_BUSY
bool invoke_http_json_rpc(const boost::string_ref uri, std::string method_name, const t_request &out_struct, t_response &result_struct, t_transport &transport, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref http_method="GET", const std::string &req_id="0")
#define CORE_RPC_STATUS_OK
unsigned __int64 uint64_t
version
Supported socks variants.