json: add GetFeeEstimate, GetAlternateChains, RelayTx

This commit is contained in:
hinto.janai 2024-07-03 20:28:43 -04:00
parent b592ee0bf8
commit 255c5540aa
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
4 changed files with 73 additions and 8 deletions

View file

@ -6,3 +6,9 @@
pub(crate) const fn is_zero(u: &u64) -> bool {
*u == 0
}
/// TODO
#[allow(clippy::trivially_copy_pass_by_ref)] // serde needs `&`
pub(crate) const fn is_one(u: &u64) -> bool {
*u == 1
}

View file

@ -6,9 +6,9 @@
use crate::{
base::{AccessResponseBase, ResponseBase},
defaults::{default_bool, default_height, default_string, default_u64, default_vec},
free::is_zero,
free::{is_one, is_zero},
macros::define_request_and_response,
misc::{BlockHeader, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry, SetBan},
misc::{BlockHeader, ChainInfo, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry, SetBan},
Status,
};
@ -471,6 +471,46 @@ define_request_and_response! {
}
}
define_request_and_response! {
get_fee_estimate,
cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 2250..=2277,
GetFeeEstimate,
Request {},
AccessResponseBase {
fee: u64,
fees: Vec<u64>,
#[serde(skip_serializing_if = "is_one")]
quantization_mask: u64,
}
}
define_request_and_response! {
get_alternate_chains,
cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 2279..=2310,
GetAlternateChains,
Request {},
ResponseBase {
chains: Vec<ChainInfo>,
}
}
define_request_and_response! {
relay_tx,
cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 2361..=2381,
RelayTx,
Request {
txids: Vec<String>,
},
#[cfg_attr(feature = "serde", serde(transparent))]
#[repr(transparent)]
Response {
status: Status,
}
}
//---------------------------------------------------------------------------------------------------- Tests
#[cfg(test)]
mod test {

View file

@ -124,4 +124,6 @@ pub mod json;
pub mod other;
mod misc;
pub use misc::{BlockHeader, ConnectionInfo};
pub use misc::{
BlockHeader, ChainInfo, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry, SetBan,
};

View file

@ -47,7 +47,7 @@ macro_rules! define_struct_and_impl_epee {
};
}
//---------------------------------------------------------------------------------------------------- BlockHeader
//---------------------------------------------------------------------------------------------------- Type Definitions
define_struct_and_impl_epee! {
#[doc = monero_definition_link!(
cc73fe71162d564ffda8e549b79a350bca53c454,
@ -89,7 +89,6 @@ define_struct_and_impl_epee! {
}
}
//---------------------------------------------------------------------------------------------------- ConnectionInfo
define_struct_and_impl_epee! {
#[doc = monero_definition_link!(
cc73fe71162d564ffda8e549b79a350bca53c454,
@ -129,7 +128,6 @@ define_struct_and_impl_epee! {
}
}
//---------------------------------------------------------------------------------------------------- Ban
define_struct_and_impl_epee! {
#[doc = monero_definition_link!(
cc73fe71162d564ffda8e549b79a350bca53c454,
@ -163,7 +161,6 @@ define_struct_and_impl_epee! {
}
}
//---------------------------------------------------------------------------------------------------- HistogramEntry
define_struct_and_impl_epee! {
#[doc = monero_definition_link!(
cc73fe71162d564ffda8e549b79a350bca53c454,
@ -181,7 +178,6 @@ define_struct_and_impl_epee! {
}
}
//---------------------------------------------------------------------------------------------------- HardforkEntry
define_struct_and_impl_epee! {
#[doc = monero_definition_link!(
cc73fe71162d564ffda8e549b79a350bca53c454,
@ -197,6 +193,27 @@ define_struct_and_impl_epee! {
}
}
define_struct_and_impl_epee! {
#[doc = monero_definition_link!(
cc73fe71162d564ffda8e549b79a350bca53c454,
"rpc/core_rpc_server_commands_defs.h",
2289..=2310
)]
/// Used in [`crate::json::GetAlternateChainsResponse`].
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
ChainInfo {
block_hash: String,
block_hashes: Vec<String>,
difficulty: u64,
difficulty_top64: u64,
height: u64,
length: u64,
main_chain_parent_block: String,
wide_difficulty: String,
}
}
//---------------------------------------------------------------------------------------------------- Tests
#[cfg(test)]
mod test {