Compare commits

..

No commits in common. "57a98e58a00b4e87585f09f4e54c567bb74e1a32" and "255c5540aa3227329d589eb23b214636267348c5" have entirely different histories.

5 changed files with 6 additions and 253 deletions

View file

@ -59,8 +59,7 @@ 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: we need to figure out a type that (de)serializes correctly, `String` errors with `serde_json`
TODO: list the specific types.
# Feature flags
List of feature flags for `cuprate-rpc-types`.

View file

@ -3,7 +3,7 @@
//---------------------------------------------------------------------------------------------------- Import
//---------------------------------------------------------------------------------------------------- BinaryString
/// TODO: we need to figure out a type that (de)serializes correctly, `String` errors with `serde_json`
/// TODO
///
/// ```rust
/// use serde::Deserialize;

View file

@ -8,11 +8,8 @@ use crate::{
defaults::{default_bool, default_height, default_string, default_u64, default_vec},
free::{is_one, is_zero},
macros::define_request_and_response,
misc::{
AuxPow, BlockHeader, ChainInfo, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry,
Peer, SetBan, Span, TxBacklogEntry,
},
OutputDistributionData, Status,
misc::{BlockHeader, ChainInfo, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry, SetBan},
Status,
};
//---------------------------------------------------------------------------------------------------- Struct definitions
@ -108,7 +105,6 @@ define_request_and_response! {
// type alias to `()` instead of a `struct`.
Request {},
#[derive(Copy)]
ResponseBase {
count: u64,
}
@ -119,6 +115,7 @@ define_request_and_response! {
cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 935..=939,
OnGetBlockHash,
#[derive(Copy)]
/// ```rust
/// use serde_json::*;
/// use cuprate_rpc_types::json::*;
@ -129,7 +126,6 @@ define_request_and_response! {
/// ```
#[cfg_attr(feature = "serde", serde(transparent))]
#[repr(transparent)]
#[derive(Copy)]
Request {
// This is `std::vector<u64>` in `monerod` but
// it must be a 1 length array or else it will error.
@ -205,7 +201,6 @@ define_request_and_response! {
cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 1214..=1238,
GetLastBlockHeader,
#[derive(Copy)]
Request {
#[cfg_attr(feature = "serde", serde(default = "default_bool"))]
fill_pow_hash: bool = default_bool(),
@ -237,7 +232,6 @@ define_request_and_response! {
cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 1271..=1296,
GetBlockHeaderByHeight,
#[derive(Copy)]
Request {
height: u64,
#[cfg_attr(feature = "serde", serde(default = "default_bool"))]
@ -253,7 +247,6 @@ define_request_and_response! {
cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 1756..=1783,
GetBlockHeadersRange,
#[derive(Copy)]
Request {
start_height: u64,
end_height: u64,
@ -401,7 +394,6 @@ define_request_and_response! {
Request {
address: String,
},
#[derive(Copy)]
Response {
banned: bool,
seconds: u32,
@ -418,7 +410,6 @@ define_request_and_response! {
#[cfg_attr(feature = "serde", serde(default = "default_vec"))]
txids: Vec<String> = default_vec::<String>(),
},
#[derive(Copy)]
#[cfg_attr(feature = "serde", serde(transparent))]
#[repr(transparent)]
Response {
@ -513,7 +504,6 @@ define_request_and_response! {
Request {
txids: Vec<String>,
},
#[derive(Copy)]
#[cfg_attr(feature = "serde", serde(transparent))]
#[repr(transparent)]
Response {
@ -521,139 +511,6 @@ define_request_and_response! {
}
}
define_request_and_response! {
sync_info,
cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 2383..=2443,
SyncInfo,
Request {},
AccessResponseBase {
height: u64,
next_needed_pruning_seed: u32,
overview: String,
// TODO: This is a `std::list` in `monerod` because...?
peers: Vec<Peer>,
// TODO: This is a `std::list` in `monerod` because...?
spans: Vec<Span>,
target_height: u64,
}
}
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>,
}
}
define_request_and_response! {
get_miner_data,
cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 996..=1044,
GetMinerData,
Request {},
ResponseBase {
major_version: u8,
height: u64,
prev_id: String,
seed_hash: String,
difficulty: String,
median_weight: u64,
already_generated_coins: u64,
}
}
define_request_and_response! {
prune_blockchain,
cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 2747..=2772,
PruneBlockchain,
#[derive(Copy)]
Request {
#[cfg_attr(feature = "serde", serde(default = "default_bool"))]
check: bool = default_bool(),
},
#[derive(Copy)]
ResponseBase {
pruned: bool,
pruning_seed: u32,
}
}
define_request_and_response! {
calc_pow,
cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 1046..=1066,
CalcPow,
Request {
major_version: u8,
height: u64,
block_blob: String,
seed_hash: String,
},
#[cfg_attr(feature = "serde", serde(transparent))]
#[repr(transparent)]
Response {
pow_hash: String,
}
}
define_request_and_response! {
flush_cache,
cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 2774..=2796,
FlushCache,
Request {
#[cfg_attr(feature = "serde", serde(default = "default_bool"))]
bad_txs: bool = default_bool(),
#[cfg_attr(feature = "serde", serde(default = "default_bool"))]
bad_blocks: bool = default_bool(),
},
ResponseBase {}
}
define_request_and_response! {
add_aux_pow,
cc73fe71162d564ffda8e549b79a350bca53c454 =>
core_rpc_server_commands_defs.h => 1068..=1112,
AddAuxPow,
Request {
blocktemplate_blob: String,
aux_pow: Vec<AuxPow>,
},
ResponseBase {
blocktemplate_blob: String,
blockhashing_blob: String,
merkle_root: String,
merkle_tree_depth: u64,
aux_pow: Vec<AuxPow>,
}
}
//---------------------------------------------------------------------------------------------------- Tests
#[cfg(test)]
mod test {

View file

@ -125,6 +125,5 @@ pub mod other;
mod misc;
pub use misc::{
AuxPow, BlockHeader, ChainInfo, ConnectionInfo, GetBan, GetMinerDataTxBacklogEntry,
HardforkEntry, HistogramEntry, OutputDistributionData, Peer, SetBan, Span, TxBacklogEntry,
BlockHeader, ChainInfo, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry, SetBan,
};

View file

@ -214,108 +214,6 @@ define_struct_and_impl_epee! {
}
}
define_struct_and_impl_epee! {
#[doc = monero_definition_link!(
cc73fe71162d564ffda8e549b79a350bca53c454,
"rpc/core_rpc_server_commands_defs.h",
2393..=2400
)]
/// Used in [`crate::json::SyncInfoResponse`].
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
Peer {
info: ConnectionInfo,
}
}
define_struct_and_impl_epee! {
#[doc = monero_definition_link!(
cc73fe71162d564ffda8e549b79a350bca53c454,
"rpc/core_rpc_server_commands_defs.h",
2402..=2421
)]
/// Used in [`crate::json::SyncInfoResponse`].
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
Span {
connection_id: String,
nblocks: u64,
rate: u32,
remote_address: String,
size: u64,
speed: u32,
start_block_height: u64,
}
}
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,
}
}
define_struct_and_impl_epee! {
#[doc = monero_definition_link!(
cc73fe71162d564ffda8e549b79a350bca53c454,
"rpc/core_rpc_server_commands_defs.h",
1016..=1027
)]
/// Used in [`crate::json::GetMinerDataResponse`].
///
/// Note that this is different than [`crate::misc::TxbacklogEntry`].
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
GetMinerDataTxBacklogEntry {
id: String,
weight: u64,
fee: u64,
}
}
define_struct_and_impl_epee! {
#[doc = monero_definition_link!(
cc73fe71162d564ffda8e549b79a350bca53c454,
"rpc/core_rpc_server_commands_defs.h",
1070..=1079
)]
/// Used in [`crate::json::GetAuxPowRequest`].
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
AuxPow {
id: String,
hash: String,
}
}
//---------------------------------------------------------------------------------------------------- Custom serde
// This section is for `struct`s that have custom (de)serialization code.
//---------------------------------------------------------------------------------------------------- Tests
#[cfg(test)]
mod test {