mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-11-16 15:58:14 +00:00
json: add GetVersion
, GetCoinbaseTxSum
, GetOutputHistogram
, FlushTransactionPool
, Banned
This commit is contained in:
parent
ea7f6fb2a5
commit
b592ee0bf8
5 changed files with 147 additions and 3 deletions
|
@ -28,6 +28,18 @@ pub(crate) const fn default_height() -> u64 {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// TODO
|
||||||
|
#[inline]
|
||||||
|
pub(crate) const fn default_vec<T>() -> Vec<T> {
|
||||||
|
Vec::new()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// TODO
|
||||||
|
#[inline]
|
||||||
|
pub(crate) const fn default_u64() -> u64 {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Tests
|
//---------------------------------------------------------------------------------------------------- Tests
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
8
rpc/types/src/free.rs
Normal file
8
rpc/types/src/free.rs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
//! Macros.
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------- TODO
|
||||||
|
/// TODO
|
||||||
|
#[allow(clippy::trivially_copy_pass_by_ref)] // serde needs `&`
|
||||||
|
pub(crate) const fn is_zero(u: &u64) -> bool {
|
||||||
|
*u == 0
|
||||||
|
}
|
|
@ -5,9 +5,11 @@
|
||||||
//---------------------------------------------------------------------------------------------------- Import
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
use crate::{
|
use crate::{
|
||||||
base::{AccessResponseBase, ResponseBase},
|
base::{AccessResponseBase, ResponseBase},
|
||||||
defaults::{default_bool, default_height, default_string},
|
defaults::{default_bool, default_height, default_string, default_u64, default_vec},
|
||||||
|
free::is_zero,
|
||||||
macros::define_request_and_response,
|
macros::define_request_and_response,
|
||||||
misc::{BlockHeader, ConnectionInfo, GetBan, SetBan},
|
misc::{BlockHeader, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry, SetBan},
|
||||||
|
Status,
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Struct definitions
|
//---------------------------------------------------------------------------------------------------- Struct definitions
|
||||||
|
@ -374,7 +376,7 @@ define_request_and_response! {
|
||||||
define_request_and_response! {
|
define_request_and_response! {
|
||||||
get_bans,
|
get_bans,
|
||||||
cc73fe71162d564ffda8e549b79a350bca53c454 =>
|
cc73fe71162d564ffda8e549b79a350bca53c454 =>
|
||||||
core_rpc_server_commands_defs.h => 2032..=2067,
|
core_rpc_server_commands_defs.h => 1997..=2030,
|
||||||
GetBans,
|
GetBans,
|
||||||
Request {},
|
Request {},
|
||||||
ResponseBase {
|
ResponseBase {
|
||||||
|
@ -382,6 +384,93 @@ define_request_and_response! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define_request_and_response! {
|
||||||
|
banned,
|
||||||
|
cc73fe71162d564ffda8e549b79a350bca53c454 =>
|
||||||
|
core_rpc_server_commands_defs.h => 2069..=2094,
|
||||||
|
Banned,
|
||||||
|
#[cfg_attr(feature = "serde", serde(transparent))]
|
||||||
|
#[repr(transparent)]
|
||||||
|
Request {
|
||||||
|
address: String,
|
||||||
|
},
|
||||||
|
Response {
|
||||||
|
banned: bool,
|
||||||
|
seconds: u32,
|
||||||
|
status: Status,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_request_and_response! {
|
||||||
|
flush_txpool,
|
||||||
|
cc73fe71162d564ffda8e549b79a350bca53c454 =>
|
||||||
|
core_rpc_server_commands_defs.h => 2096..=2116,
|
||||||
|
FlushTransactionPool,
|
||||||
|
Request {
|
||||||
|
#[cfg_attr(feature = "serde", serde(default = "default_vec"))]
|
||||||
|
txids: Vec<String> = default_vec::<String>(),
|
||||||
|
},
|
||||||
|
#[cfg_attr(feature = "serde", serde(transparent))]
|
||||||
|
#[repr(transparent)]
|
||||||
|
Response {
|
||||||
|
status: Status,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_request_and_response! {
|
||||||
|
get_output_histogram,
|
||||||
|
cc73fe71162d564ffda8e549b79a350bca53c454 =>
|
||||||
|
core_rpc_server_commands_defs.h => 2118..=2168,
|
||||||
|
GetOutputHistogram,
|
||||||
|
Request {
|
||||||
|
amounts: Vec<u64>,
|
||||||
|
min_count: u64,
|
||||||
|
max_count: u64,
|
||||||
|
unlocked: bool,
|
||||||
|
recent_cutoff: u64,
|
||||||
|
},
|
||||||
|
AccessResponseBase {
|
||||||
|
histogram: Vec<HistogramEntry>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_request_and_response! {
|
||||||
|
get_coinbase_tx_sum,
|
||||||
|
cc73fe71162d564ffda8e549b79a350bca53c454 =>
|
||||||
|
core_rpc_server_commands_defs.h => 2213..=2248,
|
||||||
|
GetCoinbaseTxSum,
|
||||||
|
Request {
|
||||||
|
height: u64,
|
||||||
|
count: u64,
|
||||||
|
},
|
||||||
|
AccessResponseBase {
|
||||||
|
emission_amount: u64,
|
||||||
|
emission_amount_top64: u64,
|
||||||
|
fee_amount: u64,
|
||||||
|
fee_amount_top64: u64,
|
||||||
|
wide_emission_amount: String,
|
||||||
|
wide_fee_amount: String,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_request_and_response! {
|
||||||
|
get_version,
|
||||||
|
cc73fe71162d564ffda8e549b79a350bca53c454 =>
|
||||||
|
core_rpc_server_commands_defs.h => 2170..=2211,
|
||||||
|
GetVersion,
|
||||||
|
Request {},
|
||||||
|
ResponseBase {
|
||||||
|
version: u32,
|
||||||
|
release: bool,
|
||||||
|
#[serde(skip_serializing_if = "is_zero", default = "default_u64")]
|
||||||
|
current_height: u64 = default_u64(),
|
||||||
|
#[serde(skip_serializing_if = "is_zero", default = "default_u64")]
|
||||||
|
target_height: u64 = default_u64(),
|
||||||
|
#[serde(skip_serializing_if = "Vec::is_empty", default = "default_vec")]
|
||||||
|
hard_forks: Vec<HardforkEntry> = default_vec(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Tests
|
//---------------------------------------------------------------------------------------------------- Tests
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
|
@ -100,6 +100,7 @@
|
||||||
mod binary_string;
|
mod binary_string;
|
||||||
mod constants;
|
mod constants;
|
||||||
mod defaults;
|
mod defaults;
|
||||||
|
mod free;
|
||||||
mod macros;
|
mod macros;
|
||||||
mod status;
|
mod status;
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,40 @@ define_struct_and_impl_epee! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------- HistogramEntry
|
||||||
|
define_struct_and_impl_epee! {
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
cc73fe71162d564ffda8e549b79a350bca53c454,
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2139..=2156
|
||||||
|
)]
|
||||||
|
/// Used in [`crate::json::GetOutputHistogramResponse`].
|
||||||
|
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
HistogramEntry {
|
||||||
|
amount: u64,
|
||||||
|
total_instances: u64,
|
||||||
|
unlocked_instances: u64,
|
||||||
|
recent_instances: u64,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------- HardforkEntry
|
||||||
|
define_struct_and_impl_epee! {
|
||||||
|
#[doc = monero_definition_link!(
|
||||||
|
cc73fe71162d564ffda8e549b79a350bca53c454,
|
||||||
|
"rpc/core_rpc_server_commands_defs.h",
|
||||||
|
2180..=2191
|
||||||
|
)]
|
||||||
|
/// Used in [`crate::json::GetVersionResponse`].
|
||||||
|
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
HardforkEntry {
|
||||||
|
height: u64,
|
||||||
|
hf_version: u8,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Tests
|
//---------------------------------------------------------------------------------------------------- Tests
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
Loading…
Reference in a new issue