more in-depth validator staking status
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
39818f848e
commit
2d01ef73c7
@ -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.45"
|
version = "0.3.46"
|
||||||
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"
|
||||||
|
@ -105,7 +105,6 @@ pub enum Action {
|
|||||||
GetSlashingSpans([u8; 32], bool),
|
GetSlashingSpans([u8; 32], bool),
|
||||||
GetValidatorLatestClaim([u8; 32], bool),
|
GetValidatorLatestClaim([u8; 32], bool),
|
||||||
GetValidatorIsDisabled([u8; 32], bool),
|
GetValidatorIsDisabled([u8; 32], bool),
|
||||||
GetValidatorInSession([u8; 32], bool),
|
|
||||||
GetCurrentValidatorEraRewards,
|
GetCurrentValidatorEraRewards,
|
||||||
|
|
||||||
SetNodeName(Option<String>),
|
SetNodeName(Option<String>),
|
||||||
@ -135,7 +134,6 @@ pub enum Action {
|
|||||||
SetValidatorEraSlash(u32, u128),
|
SetValidatorEraSlash(u32, u128),
|
||||||
SetValidatorEraUnlocking(Vec<UnlockChunk>, [u8; 32]),
|
SetValidatorEraUnlocking(Vec<UnlockChunk>, [u8; 32]),
|
||||||
SetValidatorLatestClaim(u32, [u8; 32]),
|
SetValidatorLatestClaim(u32, [u8; 32]),
|
||||||
SetValidatorInSession(bool, [u8; 32]),
|
|
||||||
SetIsBonded(bool, [u8; 32]),
|
SetIsBonded(bool, [u8; 32]),
|
||||||
SetStakedAmountRatio(Option<u128>, Option<u128>, [u8; 32]),
|
SetStakedAmountRatio(Option<u128>, Option<u128>, [u8; 32]),
|
||||||
SetStakedRatio(u128, u128, [u8; 32]),
|
SetStakedRatio(u128, u128, [u8; 32]),
|
||||||
|
@ -73,9 +73,9 @@ impl CurrentValidatorDetails {
|
|||||||
|
|
||||||
fn prepare_state_string(&self) -> String {
|
fn prepare_state_string(&self) -> String {
|
||||||
if self.is_active_validator {
|
if self.is_active_validator {
|
||||||
"active staking".to_string()
|
"active".to_string()
|
||||||
} else {
|
} else {
|
||||||
"stop staking".to_string()
|
"chilling".to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ use ratatui::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{PartialComponent, Component, CurrentTab};
|
use super::{PartialComponent, Component, CurrentTab};
|
||||||
|
use crate::types::EraRewardPoints;
|
||||||
use crate::widgets::DotSpinner;
|
use crate::widgets::DotSpinner;
|
||||||
use crate::{
|
use crate::{
|
||||||
action::Action,
|
action::Action,
|
||||||
@ -23,8 +24,10 @@ pub struct RewardDetails {
|
|||||||
inflation: String,
|
inflation: String,
|
||||||
stash: [u8; 32],
|
stash: [u8; 32],
|
||||||
in_staking_validators: bool,
|
in_staking_validators: bool,
|
||||||
in_session_validators: bool,
|
in_queued_keys: bool,
|
||||||
|
in_next_keys: bool,
|
||||||
is_disabled: bool,
|
is_disabled: bool,
|
||||||
|
in_rewards: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for RewardDetails {
|
impl Default for RewardDetails {
|
||||||
@ -43,8 +46,10 @@ impl RewardDetails {
|
|||||||
inflation: String::from("0.0%"),
|
inflation: String::from("0.0%"),
|
||||||
stash: [0u8; 32],
|
stash: [0u8; 32],
|
||||||
in_staking_validators: false,
|
in_staking_validators: false,
|
||||||
in_session_validators: false,
|
in_queued_keys: false,
|
||||||
|
in_next_keys: false,
|
||||||
is_disabled: false,
|
is_disabled: false,
|
||||||
|
in_rewards: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +62,16 @@ impl RewardDetails {
|
|||||||
None => DotSpinner::default().to_string(),
|
None => DotSpinner::default().to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_individual(&mut self, individual: &Vec<EraRewardPoints>) {
|
||||||
|
let (is_disabled, in_rewards) = individual
|
||||||
|
.iter()
|
||||||
|
.find(|data| data.account_id == self.stash)
|
||||||
|
.map(|data| (data.disabled, true))
|
||||||
|
.unwrap_or((false, false));
|
||||||
|
self.is_disabled = is_disabled;
|
||||||
|
self.in_rewards = in_rewards;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialComponent for RewardDetails {
|
impl PartialComponent for RewardDetails {
|
||||||
@ -81,18 +96,19 @@ impl Component for RewardDetails {
|
|||||||
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
||||||
match action {
|
match action {
|
||||||
Action::SetStashAccount(stash) => self.stash = stash,
|
Action::SetStashAccount(stash) => self.stash = stash,
|
||||||
Action::SetCurrentValidatorEraRewards(_, _, individual) => self.is_disabled = individual
|
Action::SetCurrentValidatorEraRewards(_, _, individual) => self.update_individual(&individual),
|
||||||
.iter()
|
|
||||||
.find(|data| data.account_id == self.stash)
|
|
||||||
.map(|data| data.disabled)
|
|
||||||
.unwrap_or_default(),
|
|
||||||
Action::SetValidatorInSession(in_session_validators, account_id) if self.stash == account_id =>
|
|
||||||
self.in_session_validators = in_session_validators,
|
|
||||||
Action::SetValidatorPrefs(commission, disabled, account_id) if self.stash == account_id => {
|
Action::SetValidatorPrefs(commission, disabled, account_id) if self.stash == account_id => {
|
||||||
self.commission = commission;
|
self.commission = commission;
|
||||||
self.in_staking_validators = commission.is_some();
|
self.in_staking_validators = commission.is_some();
|
||||||
self.nominators_blocked = disabled;
|
self.nominators_blocked = disabled;
|
||||||
}
|
}
|
||||||
|
Action::SetSessionKey(name, session_key_info) => {
|
||||||
|
if name.starts_with("q_") {
|
||||||
|
self.in_queued_keys = !session_key_info.key.is_empty();
|
||||||
|
} else {
|
||||||
|
self.in_next_keys = !session_key_info.key.is_empty();
|
||||||
|
}
|
||||||
|
},
|
||||||
Action::Apy(apy) => self.apy = apy,
|
Action::Apy(apy) => self.apy = apy,
|
||||||
Action::Inflation(inflation) => self.inflation = inflation,
|
Action::Inflation(inflation) => self.inflation = inflation,
|
||||||
_ => {}
|
_ => {}
|
||||||
@ -104,16 +120,19 @@ impl Component for RewardDetails {
|
|||||||
let [_, _, place] = super::validator_balance_layout(area);
|
let [_, _, place] = super::validator_balance_layout(area);
|
||||||
let (border_style, border_type) = self.palette.create_border_style(false);
|
let (border_style, border_type) = self.palette.create_border_style(false);
|
||||||
|
|
||||||
let staking_status = if self.is_disabled {
|
let status = if self.is_disabled {
|
||||||
"Staking status: Disabled".to_string()
|
"Disabled"
|
||||||
} else {
|
} else {
|
||||||
match (self.in_staking_validators, self.in_session_validators) {
|
let is_fully_in_session = self.in_queued_keys && self.in_next_keys;
|
||||||
(false, false) => "Staking status: Nothing".to_string(),
|
match (self.in_staking_validators, is_fully_in_session) {
|
||||||
(true, false) => "Staking status: Stopping".to_string(),
|
(true, true) => "Active",
|
||||||
(false, true) => "Staking status: Pending".to_string(),
|
(true, false) => "Rotating",
|
||||||
(true, true) => "Staking status: Active".to_string(),
|
(false, true) if self.in_rewards => { "Stopping" }
|
||||||
|
(false, true) if !self.in_rewards => { "Chill" }
|
||||||
|
_ => "Nothing",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
let staking_status = format!("Staking status: {status}");
|
||||||
|
|
||||||
let table = Table::new(
|
let table = Table::new(
|
||||||
vec![
|
vec![
|
||||||
|
@ -160,7 +160,6 @@ impl StashInfo {
|
|||||||
let _ = network_tx.send(Action::GetValidatorAllRewards(account_id, true));
|
let _ = network_tx.send(Action::GetValidatorAllRewards(account_id, true));
|
||||||
let _ = network_tx.send(Action::GetSlashingSpans(account_id, true));
|
let _ = network_tx.send(Action::GetSlashingSpans(account_id, true));
|
||||||
let _ = network_tx.send(Action::GetValidatorIsDisabled(account_id, true));
|
let _ = network_tx.send(Action::GetValidatorIsDisabled(account_id, true));
|
||||||
let _ = network_tx.send(Action::GetValidatorInSession(account_id, true));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,6 @@ impl Network {
|
|||||||
predefined_calls::get_is_stash_bonded(&self.action_tx, &self.online_client_api, &stash_to_watch).await?;
|
predefined_calls::get_is_stash_bonded(&self.action_tx, &self.online_client_api, &stash_to_watch).await?;
|
||||||
predefined_calls::get_validators_ledger(&self.action_tx, &self.online_client_api, &stash_to_watch).await?;
|
predefined_calls::get_validators_ledger(&self.action_tx, &self.online_client_api, &stash_to_watch).await?;
|
||||||
predefined_calls::get_slashing_spans(&self.action_tx, &self.online_client_api, &stash_to_watch).await?;
|
predefined_calls::get_slashing_spans(&self.action_tx, &self.online_client_api, &stash_to_watch).await?;
|
||||||
predefined_calls::get_validator_in_session(&self.action_tx, &self.online_client_api, &stash_to_watch).await?;
|
|
||||||
|
|
||||||
for era_index in self.eras_to_watch.iter() {
|
for era_index in self.eras_to_watch.iter() {
|
||||||
predefined_calls::get_validator_staking_result(&self.action_tx, &self.online_client_api, &stash_to_watch, *era_index).await?;
|
predefined_calls::get_validator_staking_result(&self.action_tx, &self.online_client_api, &stash_to_watch, *era_index).await?;
|
||||||
@ -209,10 +208,6 @@ impl Network {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
Action::GetValidatorInSession(account_id, is_stash) => {
|
|
||||||
self.store_stash_or_validator_if_possible(account_id, is_stash);
|
|
||||||
predefined_calls::get_validator_in_session(&self.action_tx, &self.online_client_api, &account_id).await
|
|
||||||
}
|
|
||||||
Action::GetValidatorLatestClaim(account_id, is_stash) => {
|
Action::GetValidatorLatestClaim(account_id, is_stash) => {
|
||||||
self.store_stash_or_validator_if_possible(account_id, is_stash);
|
self.store_stash_or_validator_if_possible(account_id, is_stash);
|
||||||
predefined_calls::get_validator_latest_claim(&self.action_tx, &self.online_client_api, &account_id).await
|
predefined_calls::get_validator_latest_claim(&self.action_tx, &self.online_client_api, &account_id).await
|
||||||
|
@ -581,18 +581,3 @@ pub async fn get_validator_latest_claim(
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_validator_in_session(
|
|
||||||
action_tx: &UnboundedSender<Action>,
|
|
||||||
api: &OnlineClient<CasperConfig>,
|
|
||||||
account_id: &[u8; 32],
|
|
||||||
) -> Result<()> {
|
|
||||||
let in_list = super::raw_calls::session::validators(api, None)
|
|
||||||
.await?
|
|
||||||
.unwrap_or_default()
|
|
||||||
.iter()
|
|
||||||
.position(|validator| validator.0 == *account_id)
|
|
||||||
.is_some();
|
|
||||||
action_tx.send(Action::SetValidatorInSession(in_list, *account_id))?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user