From c4f0f6f35c8fbf7d14db0f4c55f13c1974fb67d0 Mon Sep 17 00:00:00 2001 From: Uncle Stretch Date: Tue, 18 Feb 2025 17:54:20 +0300 Subject: [PATCH] validator status detection draft added Signed-off-by: Uncle Stretch --- Cargo.toml | 2 +- src/components/validator/reward_details.rs | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d82e535..3ac5ae7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "ghost-eye" authors = ["str3tch "] description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost" -version = "0.3.39" +version = "0.3.40" edition = "2021" [dependencies] diff --git a/src/components/validator/reward_details.rs b/src/components/validator/reward_details.rs index dfbfb61..b305c73 100644 --- a/src/components/validator/reward_details.rs +++ b/src/components/validator/reward_details.rs @@ -22,6 +22,8 @@ pub struct RewardDetails { apy: String, inflation: String, stash: [u8; 32], + in_staking_validators: bool, + in_session_validators: bool, } impl Default for RewardDetails { @@ -39,6 +41,8 @@ impl RewardDetails { apy: String::from("0.0%"), inflation: String::from("0.0%"), stash: [0u8; 32], + in_staking_validators: false, + in_session_validators: false, } } @@ -77,6 +81,7 @@ impl Component for RewardDetails { Action::SetStashAccount(stash) => self.stash = stash, Action::SetValidatorPrefs(commission, disabled, account_id) if self.stash == account_id => { self.commission = commission; + self.in_staking_validators = commission.is_some(); self.nominators_blocked = disabled; } Action::Apy(apy) => self.apy = apy, @@ -90,6 +95,13 @@ impl Component for RewardDetails { let [_, _, place] = super::validator_balance_layout(area); let (border_style, border_type) = self.palette.create_border_style(false); + let staking_status = match (self.in_staking_validators, self.in_session_validators) { + (false, false) => "Staking status: Nothing".to_string(), + (true, false) => "Staking status: Active".to_string(), + (false, true) => "Staking status: Pending".to_string(), + (true, true) => "Staking status: Active".to_string(), + }; + let table = Table::new( vec![ Row::new(vec![ @@ -117,7 +129,7 @@ impl Component for RewardDetails { .border_type(border_type) .title_alignment(Alignment::Right) .title_style(self.palette.create_title_style(false)) - .title("Reward details")); + .title(staking_status)); frame.render_widget(table, place);