From 32730272ea4c764d116ed85c6b27f39bbc00a0fe Mon Sep 17 00:00:00 2001 From: "hinto.janai" Date: Wed, 3 Jul 2024 20:34:45 -0400 Subject: [PATCH] json: add `SyncInfo` --- rpc/types/src/json.rs | 23 ++++++++++++++++++++++- rpc/types/src/lib.rs | 2 +- rpc/types/src/misc.rs | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/rpc/types/src/json.rs b/rpc/types/src/json.rs index 2b7a592..2eb0c65 100644 --- a/rpc/types/src/json.rs +++ b/rpc/types/src/json.rs @@ -8,7 +8,10 @@ use crate::{ defaults::{default_bool, default_height, default_string, default_u64, default_vec}, free::{is_one, is_zero}, macros::define_request_and_response, - misc::{BlockHeader, ChainInfo, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry, SetBan}, + misc::{ + BlockHeader, ChainInfo, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry, Peer, + SetBan, Span, + }, Status, }; @@ -511,6 +514,24 @@ define_request_and_response! { } } +define_request_and_response! { + sync_info, + cc73fe71162d564ffda8e549b79a350bca53c454 => + core_rpc_server_commands_defs.h => 2383..=2443, + SyncInfo, + Request {}, + Response { + height: u64, + next_needed_pruning_seed: u32, + overview: String, + // TODO: This is a `std::list` in `monerod` because...? + peers: Vec, + // TODO: This is a `std::list` in `monerod` because...? + spans: Vec, + target_height: u64, + } +} + //---------------------------------------------------------------------------------------------------- Tests #[cfg(test)] mod test { diff --git a/rpc/types/src/lib.rs b/rpc/types/src/lib.rs index f6f42c5..0235de2 100644 --- a/rpc/types/src/lib.rs +++ b/rpc/types/src/lib.rs @@ -125,5 +125,5 @@ pub mod other; mod misc; pub use misc::{ - BlockHeader, ChainInfo, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry, SetBan, + BlockHeader, ChainInfo, ConnectionInfo, GetBan, HardforkEntry, HistogramEntry, SetBan, Peer, Span, }; diff --git a/rpc/types/src/misc.rs b/rpc/types/src/misc.rs index 6d52403..05ed89c 100644 --- a/rpc/types/src/misc.rs +++ b/rpc/types/src/misc.rs @@ -214,6 +214,40 @@ 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, + } +} + //---------------------------------------------------------------------------------------------------- Tests #[cfg(test)] mod test {