per_kb_fee_estimated added

master
moneroexamples 1 year ago
parent aa96ce2927
commit 31490c319d

@ -5695,17 +5695,29 @@ json_networkinfo()
return j_response;
}
uint64_t fee_estimated {0};
uint64_t per_kb_fee_estimated {0};
// get dynamic fee estimate from last 10 blocks
if (!get_dynamic_per_kb_fee_estimate(fee_estimated))
if (!get_dynamic_per_kb_fee_estimate(per_kb_fee_estimated))
{
j_response["status"] = "error";
j_response["message"] = "Cant get dynamic fee esimate";
j_response["message"] = "Cant get per kb dynamic fee esimate";
return j_response;
}
j_info["fee_per_kb"] = fee_estimated;
uint64_t fee_estimated {0};
// get dynamic fee estimate from last 10 blocks
//@todo: make this work
// if (!get_base_fee_estimate(fee_estimated))
// {
// j_response["status"] = "error";
// j_response["message"] = "Cant get dynamic fee esimate";
// return j_response;
// }
j_info["fee_per_kb"] = per_kb_fee_estimated;
j_info["fee_estimate"] = fee_estimated;
j_info["tx_pool_size"] = MempoolStatus::mempool_no.load();
j_info["tx_pool_size_kbytes"] = MempoolStatus::mempool_size.load();
@ -6836,6 +6848,25 @@ get_dynamic_per_kb_fee_estimate(uint64_t& fee_estimated)
return true;
}
bool
get_base_fee_estimate(uint64_t& fee_estimated)
{
string error_msg;
if (!rpc.get_base_fee_estimate(
FEE_ESTIMATE_GRACE_BLOCKS,
fee_estimated))
{
cerr << "rpc.get_base_fee_estimate failed" << endl;
return false;
}
(void) error_msg;
return true;
}
bool
are_absolute_offsets_good(
std::vector<uint64_t> const& absolute_offsets,

@ -40,6 +40,33 @@ rpccalls::connect_to_monero_daemon()
return m_http_client.connect(timeout_time_ms);
}
bool
rpccalls::get_base_fee_estimate(uint64_t grace_blocks,
uint64_t& fee_estimate) {
cryptonote::COMMAND_RPC_GET_BASE_FEE_ESTIMATE::request req;
cryptonote::COMMAND_RPC_GET_BASE_FEE_ESTIMATE::response res;
req.grace_blocks = grace_blocks;
if (!connect_to_monero_daemon())
{
cerr << "get_base_fee_estimate: not connected to daemon" << endl;
return false;
}
bool r = epee::net_utils::invoke_http_json(
"/get_fee_estimate",
req, res, m_http_client, timeout_time_ms);
fee_estimate = res.fee;
return r;
}
uint64_t
rpccalls::get_current_height()
{

@ -105,6 +105,9 @@ public:
bool
get_network_info(COMMAND_RPC_GET_INFO::response& info);
bool
get_base_fee_estimate(uint64_t grace_blocks, uint64_t& fee_estimate);
bool
get_hardfork_info( COMMAND_RPC_HARD_FORK_INFO::response& res);

@ -627,8 +627,6 @@ sum_fees_in_txs(const vector<transaction>& txs)
return fees_sum;
}
vector<output_tuple_with_tag>
get_ouputs(const transaction& tx)
{

Loading…
Cancel
Save