From 2d461ae4ea711e99cc605e21356aaa817aabb5f7 Mon Sep 17 00:00:00 2001 From: hinto-janaiyo Date: Sun, 25 Dec 2022 11:17:35 -0500 Subject: [PATCH] Status Submenu: add matching structs for monerod's [get_info] --- src/helper.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/helper.rs b/src/helper.rs index a3e99f0..b73d89f 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -1743,6 +1743,39 @@ impl Hashrate { } } +//---------------------------------------------------------------------------------------------------- PubMoneroApi +#[derive(Debug, Serialize, Deserialize, Clone)] +struct PubMoneroApi { + size: HumanNumber, // Blockchain size in GB + diff: HumanNumber, // Current difficulty + height: HumanNumber, // Current height + incoming: HumanNumber, // In-peers + outgoing: HumanNumber, // Out-peers + restricted: bool, // Is RPC in restricted mode? + synchronized: bool, // Are we synced? + tx_pool_size: HumanNumber, // Current amout of TX in TX pool +} + +//---------------------------------------------------------------------------------------------------- PrivMoneroApi +// This matches some stats from monerod's JSON-RPC HTTP call [get_info] +// It _seems_ monerod initializes stats with [0], so no [Option], hopefully nothing panics :D +#[derive(Debug, Serialize, Deserialize, Clone)] +struct PrivMoneroApi { + result: Result, +} +struct Result { + database_size: u128, // bytes + difficulty: u128, + height: u64, + incoming_connections_count: u32, + nettype: String, // mainnet, stagenet, testnet + outgoing_connections_count: u32, + restricted: bool, + status: String, // OK + synchronized: bool, + tx_pool_size: u32, // tx pool +} + //---------------------------------------------------------------------------------------------------- TESTS #[cfg(test)] mod test {