show current validators and upcoming validators on top bar

Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
Uncle Stretch 2025-12-07 14:11:28 +03:00
parent ffb2f3787e
commit 2a700101dd
Signed by: str3tch
GPG Key ID: 84F3190747EE79AA
4 changed files with 20 additions and 10 deletions

View File

@ -2,7 +2,7 @@
name = "ghost-eye" name = "ghost-eye"
authors = ["str3tch <stretch@ghostchain.io>"] authors = ["str3tch <stretch@ghostchain.io>"]
description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost" description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost"
version = "0.3.83" version = "0.3.84"
edition = "2021" edition = "2021"
homepage = "https://git.ghostchain.io/ghostchain" homepage = "https://git.ghostchain.io/ghostchain"
repository = "https://git.ghostchain.io/ghostchain/ghost-eye" repository = "https://git.ghostchain.io/ghostchain/ghost-eye"

View File

@ -77,7 +77,7 @@ pub enum Action {
NewFinalizedHash(H256), NewFinalizedHash(H256),
BestBlockUpdated(u32), BestBlockUpdated(u32),
ExtrinsicsLength(u32, usize), ExtrinsicsLength(u32, usize),
ValidatorsNumber(u32), ValidatorsNumber(u32, u32),
NominatorsNumber(u32), NominatorsNumber(u32),
Inflation(String), Inflation(String),
Apy(String), Apy(String),

View File

@ -20,7 +20,8 @@ pub struct Health {
is_syncing: bool, is_syncing: bool,
should_have_peers: bool, should_have_peers: bool,
tx_pool_length: usize, tx_pool_length: usize,
validators_count: u32, next_validators_count: u32,
current_validators_count: u32,
nominators_count: u32, nominators_count: u32,
} }
@ -38,7 +39,8 @@ impl Health {
is_syncing: true, is_syncing: true,
should_have_peers: false, should_have_peers: false,
tx_pool_length: 0, tx_pool_length: 0,
validators_count: 0, next_validators_count: 0,
current_validators_count: 0,
nominators_count: 0, nominators_count: 0,
} }
} }
@ -77,7 +79,10 @@ impl Component for Health {
Action::SetNodeName(name) => self.name = name, Action::SetNodeName(name) => self.name = name,
Action::SetPendingExtrinsicsLength(length) => self.tx_pool_length = length, Action::SetPendingExtrinsicsLength(length) => self.tx_pool_length = length,
Action::NominatorsNumber(number) => self.nominators_count = number, Action::NominatorsNumber(number) => self.nominators_count = number,
Action::ValidatorsNumber(number) => self.validators_count = number, Action::ValidatorsNumber(current, next) => {
self.current_validators_count = current;
self.next_validators_count = next;
}
_ => {} _ => {}
}; };
Ok(None) Ok(None)
@ -86,13 +91,14 @@ impl Component for Health {
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> { fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
let [place, _] = super::layouts::header_layout(area); let [place, _] = super::layouts::header_layout(area);
let message = format!("{:^12} | tx.pool: {:^3} | peers: {:^3} | {:^9} | validators {:^4} | nominators {:^4} |", let message = format!("{:^12} | tx.pool: {:^3} | peers: {:^3} | {:^9} | validators {:^4}({}) | nominators {:^4} |",
self.name_as_string(), self.name_as_string(),
self.tx_pool_length, self.tx_pool_length,
self.peers_as_string(), self.peers_as_string(),
self.is_syncing_as_string(), self.is_syncing_as_string(),
self.validators_count + 1, self.current_validators_count,
self.nominators_count + 1); self.next_validators_count,
self.nominators_count);
let span = Span::styled(message, Style::new().dim()); let span = Span::styled(message, Style::new().dim());
let paragraph = Paragraph::new(span).left_aligned(); let paragraph = Paragraph::new(span).left_aligned();

View File

@ -158,10 +158,14 @@ pub async fn get_validators_number(
action_tx: &UnboundedSender<Action>, action_tx: &UnboundedSender<Action>,
api: &OnlineClient<CasperConfig>, api: &OnlineClient<CasperConfig>,
) -> Result<()> { ) -> Result<()> {
let counter_for_validators = super::raw_calls::staking::counter_for_validators(api, None) let next_validators_count = super::raw_calls::staking::counter_for_validators(api, None)
.await? .await?
.unwrap_or_default(); .unwrap_or_default();
action_tx.send(Action::ValidatorsNumber(counter_for_validators))?; let current_validators_count = super::raw_calls::session::validators(api, None)
.await?
.map(|validators| validators.len() as u32)
.unwrap_or_default();
action_tx.send(Action::ValidatorsNumber(current_validators_count, next_validators_count))?;
Ok(()) Ok(())
} }