Merge pull request #9958

9002681 Add new dynamic fees to ZMQ (Lee Clagett)
This commit is contained in:
tobtoht 2025-07-10 17:32:31 +00:00
commit 3e218c2021
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
3 changed files with 9 additions and 1 deletions

View file

@ -843,15 +843,20 @@ namespace rpc
void DaemonHandler::handle(const GetFeeEstimate::Request& req, GetFeeEstimate::Response& res) void DaemonHandler::handle(const GetFeeEstimate::Request& req, GetFeeEstimate::Response& res)
{ {
res.hard_fork_version = m_core.get_blockchain_storage().get_current_hard_fork_version(); res.hard_fork_version = m_core.get_blockchain_storage().get_current_hard_fork_version();
res.estimated_base_fee = m_core.get_blockchain_storage().get_dynamic_base_fee_estimate(req.num_grace_blocks);
if (res.hard_fork_version < HF_VERSION_PER_BYTE_FEE) if (res.hard_fork_version < HF_VERSION_PER_BYTE_FEE)
{ {
res.fees.clear();
res.estimated_base_fee = m_core.get_blockchain_storage().get_dynamic_base_fee_estimate(req.num_grace_blocks);
res.size_scale = 1024; // per KiB fee res.size_scale = 1024; // per KiB fee
res.fee_mask = 1; res.fee_mask = 1;
} }
else else
{ {
m_core.get_blockchain_storage().get_dynamic_base_fee_estimate_2021_scaling(req.num_grace_blocks, res.fees);
res.estimated_base_fee = res.fees.at(0);
res.size_scale = 1; // per byte fee res.size_scale = 1; // per byte fee
res.fee_mask = Blockchain::get_fee_quantization_mask(); res.fee_mask = Blockchain::get_fee_quantization_mask();
} }

View file

@ -753,6 +753,7 @@ void GetFeeEstimate::Request::fromJson(const rapidjson::Value& val)
void GetFeeEstimate::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const void GetFeeEstimate::Response::doToJson(rapidjson::Writer<epee::byte_stream>& dest) const
{ {
INSERT_INTO_JSON_OBJECT(dest, fees, fees);
INSERT_INTO_JSON_OBJECT(dest, estimated_base_fee, estimated_base_fee); INSERT_INTO_JSON_OBJECT(dest, estimated_base_fee, estimated_base_fee);
INSERT_INTO_JSON_OBJECT(dest, fee_mask, fee_mask); INSERT_INTO_JSON_OBJECT(dest, fee_mask, fee_mask);
INSERT_INTO_JSON_OBJECT(dest, size_scale, size_scale); INSERT_INTO_JSON_OBJECT(dest, size_scale, size_scale);
@ -766,6 +767,7 @@ void GetFeeEstimate::Response::fromJson(const rapidjson::Value& val)
throw json::WRONG_TYPE("json object"); throw json::WRONG_TYPE("json object");
} }
GET_FROM_JSON_OBJECT(val, fees, fees);
GET_FROM_JSON_OBJECT(val, estimated_base_fee, estimated_base_fee); GET_FROM_JSON_OBJECT(val, estimated_base_fee, estimated_base_fee);
GET_FROM_JSON_OBJECT(val, fee_mask, fee_mask); GET_FROM_JSON_OBJECT(val, fee_mask, fee_mask);
GET_FROM_JSON_OBJECT(val, size_scale, size_scale); GET_FROM_JSON_OBJECT(val, size_scale, size_scale);

View file

@ -423,6 +423,7 @@ BEGIN_RPC_MESSAGE_CLASS(GetFeeEstimate);
RPC_MESSAGE_MEMBER(uint64_t, num_grace_blocks); RPC_MESSAGE_MEMBER(uint64_t, num_grace_blocks);
END_RPC_MESSAGE_REQUEST; END_RPC_MESSAGE_REQUEST;
BEGIN_RPC_MESSAGE_RESPONSE; BEGIN_RPC_MESSAGE_RESPONSE;
RPC_MESSAGE_MEMBER(std::vector<uint64_t>, fees);
RPC_MESSAGE_MEMBER(uint64_t, estimated_base_fee); RPC_MESSAGE_MEMBER(uint64_t, estimated_base_fee);
RPC_MESSAGE_MEMBER(uint64_t, fee_mask); RPC_MESSAGE_MEMBER(uint64_t, fee_mask);
RPC_MESSAGE_MEMBER(uint32_t, size_scale); RPC_MESSAGE_MEMBER(uint32_t, size_scale);