From 39cfdbfe4c215ff369144c202d9af97169f9d79c Mon Sep 17 00:00:00 2001 From: Arthur Date: Sun, 26 May 2024 16:35:08 +0100 Subject: [PATCH] Added in some display for the node_info And cleaned up a couple of things. Started on the pretty printing of some of the Monerod stuff --- src/main.rs | 11 +++++------ src/monero_rpc.rs | 12 +++++++++++- templates/index.html.tera | 32 +++++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index e9b2901..b34c978 100644 --- a/src/main.rs +++ b/src/main.rs @@ -100,12 +100,11 @@ fn get_node_info() -> NodeInfoInner { let node_info = task::block_in_place(move || { let client = reqwest::blocking::Client::new(); - // TODO: Properly handle this unwrap - half the point of this is to capture - // when the node is down - let resp = client.post("http://127.0.0.1:18081/json_rpc").json(&map).send().unwrap(); - // TODO: Make this resp.json - I need to build a deserializer I think - // TODO: Figure out _why_ this part needs to be inside this closure - resp.json::() + // TODO: Properly handle this unwrap - half the point of this is to capture + // when the node is down + let resp = client.post("http://127.0.0.1:18081/json_rpc").json(&map).send().unwrap(); + // TODO: Figure out _why_ this part needs to be inside this closure + resp.json::() }).unwrap(); node_info.result } diff --git a/src/monero_rpc.rs b/src/monero_rpc.rs index 92f357e..57275e9 100644 --- a/src/monero_rpc.rs +++ b/src/monero_rpc.rs @@ -51,5 +51,15 @@ pub struct NodeInfoInner { was_bootstrap_ever_used: bool, white_peerlist_size: u64, wide_cumulative_difficulty: String, - wide_difficulty: String + wide_difficulty: String, + #[serde(skip_deserializing, default = "none")] + time_up_pretty: Option, + #[serde(skip_deserializing, default = "none")] + space_left_pretty: Option, + #[serde(skip_deserializing, default = "none")] + db_size_pretty: Option, +} + +fn none() -> Option { + None } diff --git a/templates/index.html.tera b/templates/index.html.tera index bd22929..bbffae1 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -18,6 +18,13 @@ font-weight: bold; color: red; } + span.success { + font-weight: bold; + color: green; + } + .warning { + color: yellow; + } @@ -61,7 +68,30 @@

Monerod Status

- < +
+ {% if node_info.synchronized %} +

Synchronised to {{ node_info.nettype }}

+ {% else %} +

Synchronising to {{ node_info.nettype }}

+ {% endif %} +

Running version {{ node_info.version }} + {% if node_info.update_available %} +

Which can be updated

+ {% endif %} +
+
+

Txs in pool: {{ node_info.tx_pool_size }}

+

Total Txs: {{ node_info.tx_count }}

+
+
+

Incoming Connections: {{ node_info.incoming_connections_count }}

+

Outgoing Connections: {{ node_info.outgoing_connections_count }}

+

RPC Connections: {{ node_info.rpc_connections_count }}

+
+
+

Blockheight: {{ node_info.height }}

+

Latest block hash: {{ node_info.top_block_hash }}

+

Node Peers