mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-11-16 15:58:14 +00:00
json: add GetTransactionPoolBacklog
, GetOutputDistribution
This commit is contained in:
parent
32730272ea
commit
e19dfb40ee
5 changed files with 74 additions and 6 deletions
|
@ -59,7 +59,8 @@ values inside JSON strings, for example:
|
|||
|
||||
`binary` here is (de)serialized as a normal [`String`]. In order to be clear on which fields contain binary data, the struct fields that have them will use [`crate::BinaryString`] instead of [`String`].
|
||||
|
||||
TODO: list the specific types.
|
||||
- TODO: list the specific types.
|
||||
- TODO: we need to figure out a type that (de)serializes correctly, `String` errors with `serde_json`
|
||||
|
||||
# Feature flags
|
||||
List of feature flags for `cuprate-rpc-types`.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//---------------------------------------------------------------------------------------------------- Import
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- BinaryString
|
||||
/// TODO
|
||||
/// TODO: we need to figure out a type that (de)serializes correctly, `String` errors with `serde_json`
|
||||
///
|
||||
/// ```rust
|
||||
/// use serde::Deserialize;
|
||||
|
|
|
@ -10,9 +10,9 @@ use crate::{
|
|||
macros::define_request_and_response,
|
||||
misc::{
|
||||
BlockHeader, ChainInfo, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry, Peer,
|
||||
SetBan, Span,
|
||||
SetBan, Span, TxBacklogEntry,
|
||||
},
|
||||
Status,
|
||||
OutputDistributionData, Status,
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Struct definitions
|
||||
|
@ -520,7 +520,7 @@ define_request_and_response! {
|
|||
core_rpc_server_commands_defs.h => 2383..=2443,
|
||||
SyncInfo,
|
||||
Request {},
|
||||
Response {
|
||||
AccessResponseBase {
|
||||
height: u64,
|
||||
next_needed_pruning_seed: u32,
|
||||
overview: String,
|
||||
|
@ -532,6 +532,37 @@ define_request_and_response! {
|
|||
}
|
||||
}
|
||||
|
||||
define_request_and_response! {
|
||||
get_txpool_backlog,
|
||||
cc73fe71162d564ffda8e549b79a350bca53c454 =>
|
||||
core_rpc_server_commands_defs.h => 1637..=1664,
|
||||
GetTransactionPoolBacklog,
|
||||
Request {},
|
||||
ResponseBase {
|
||||
backlog: Vec<TxBacklogEntry>,
|
||||
}
|
||||
}
|
||||
|
||||
define_request_and_response! {
|
||||
get_output_distribution,
|
||||
cc73fe71162d564ffda8e549b79a350bca53c454 =>
|
||||
core_rpc_server_commands_defs.h => 2445..=2520,
|
||||
GetOutputDistribution,
|
||||
Request {
|
||||
amounts: Vec<u64>,
|
||||
binary: bool,
|
||||
compress: bool,
|
||||
cumulative: bool,
|
||||
from_height: u64,
|
||||
to_height: u64,
|
||||
},
|
||||
/// TODO: this request has custom serde:
|
||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server_commands_defs.h#L2468-L2508>
|
||||
AccessResponseBase {
|
||||
distributions: Vec<OutputDistributionData>,
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Tests
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
|
|
|
@ -125,5 +125,6 @@ pub mod other;
|
|||
|
||||
mod misc;
|
||||
pub use misc::{
|
||||
BlockHeader, ChainInfo, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry, SetBan, Peer, Span,
|
||||
BlockHeader, ChainInfo, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry,
|
||||
OutputDistributionData, Peer, SetBan, Span, TxBacklogEntry,
|
||||
};
|
||||
|
|
|
@ -248,6 +248,41 @@ define_struct_and_impl_epee! {
|
|||
}
|
||||
}
|
||||
|
||||
define_struct_and_impl_epee! {
|
||||
#[doc = monero_definition_link!(
|
||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
||||
"rpc/core_rpc_server_commands_defs.h",
|
||||
1637..=1642
|
||||
)]
|
||||
/// Used in [`crate::json::GetTransactionPoolBacklog`].
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
TxBacklogEntry {
|
||||
weight: u64,
|
||||
fee: u64,
|
||||
time_in_pool: u64,
|
||||
}
|
||||
}
|
||||
|
||||
define_struct_and_impl_epee! {
|
||||
#[doc = monero_definition_link!(
|
||||
cc73fe71162d564ffda8e549b79a350bca53c454,
|
||||
"rpc/rpc_handler.h",
|
||||
45..=50
|
||||
)]
|
||||
/// Used in [`crate::json::GetOutputDistribution`].
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
OutputDistributionData {
|
||||
distribution: Vec<u64>,
|
||||
start_height: u64,
|
||||
base: u64,
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Custom serde
|
||||
// This section is for `struct`s that have custom (de)serialization code.
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Tests
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
|
|
Loading…
Reference in a new issue