mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-11-16 15:58:14 +00:00
json: add GetFeeEstimate
, GetAlternateChains
, RelayTx
This commit is contained in:
parent
b592ee0bf8
commit
255c5540aa
4 changed files with 73 additions and 8 deletions
|
@ -6,3 +6,9 @@
|
||||||
pub(crate) const fn is_zero(u: &u64) -> bool {
|
pub(crate) const fn is_zero(u: &u64) -> bool {
|
||||||
*u == 0
|
*u == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// TODO
|
||||||
|
#[allow(clippy::trivially_copy_pass_by_ref)] // serde needs `&`
|
||||||
|
pub(crate) const fn is_one(u: &u64) -> bool {
|
||||||
|
*u == 1
|
||||||
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
base::{AccessResponseBase, ResponseBase},
|
base::{AccessResponseBase, ResponseBase},
|
||||||
defaults::{default_bool, default_height, default_string, default_u64, default_vec},
|
defaults::{default_bool, default_height, default_string, default_u64, default_vec},
|
||||||
free::is_zero,
|
free::{is_one, is_zero},
|
||||||
macros::define_request_and_response,
|
macros::define_request_and_response,
|
||||||
misc::{BlockHeader, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry, SetBan},
|
misc::{BlockHeader, ChainInfo, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry, SetBan},
|
||||||
Status,
|
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
|
//---------------------------------------------------------------------------------------------------- Tests
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
|
@ -124,4 +124,6 @@ pub mod json;
|
||||||
pub mod other;
|
pub mod other;
|
||||||
|
|
||||||
mod misc;
|
mod misc;
|
||||||
pub use misc::{BlockHeader, ConnectionInfo};
|
pub use misc::{
|
||||||
|
BlockHeader, ChainInfo, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry, SetBan,
|
||||||
|
};
|
||||||
|
|
|
@ -47,7 +47,7 @@ macro_rules! define_struct_and_impl_epee {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- BlockHeader
|
//---------------------------------------------------------------------------------------------------- Type Definitions
|
||||||
define_struct_and_impl_epee! {
|
define_struct_and_impl_epee! {
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
cc73fe71162d564ffda8e549b79a350bca53c454,
|
||||||
|
@ -89,7 +89,6 @@ define_struct_and_impl_epee! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- ConnectionInfo
|
|
||||||
define_struct_and_impl_epee! {
|
define_struct_and_impl_epee! {
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
cc73fe71162d564ffda8e549b79a350bca53c454,
|
||||||
|
@ -129,7 +128,6 @@ define_struct_and_impl_epee! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Ban
|
|
||||||
define_struct_and_impl_epee! {
|
define_struct_and_impl_epee! {
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
cc73fe71162d564ffda8e549b79a350bca53c454,
|
||||||
|
@ -163,7 +161,6 @@ define_struct_and_impl_epee! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- HistogramEntry
|
|
||||||
define_struct_and_impl_epee! {
|
define_struct_and_impl_epee! {
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
cc73fe71162d564ffda8e549b79a350bca53c454,
|
||||||
|
@ -181,7 +178,6 @@ define_struct_and_impl_epee! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- HardforkEntry
|
|
||||||
define_struct_and_impl_epee! {
|
define_struct_and_impl_epee! {
|
||||||
#[doc = monero_definition_link!(
|
#[doc = monero_definition_link!(
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
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
|
//---------------------------------------------------------------------------------------------------- Tests
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
Loading…
Reference in a new issue