fix for the staker status
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
ee5640349a
commit
bb5a0e8eba
@ -105,6 +105,8 @@ pub enum Action {
|
|||||||
GetValidatorPrefs([u8; 32], bool),
|
GetValidatorPrefs([u8; 32], bool),
|
||||||
GetSlashingSpans([u8; 32], bool),
|
GetSlashingSpans([u8; 32], bool),
|
||||||
GetValidatorLatestClaim([u8; 32], bool),
|
GetValidatorLatestClaim([u8; 32], bool),
|
||||||
|
GetValidatorIsDisabled([u8; 32], bool),
|
||||||
|
GetValidatorInSession([u8; 32], bool),
|
||||||
GetCurrentValidatorEraRewards,
|
GetCurrentValidatorEraRewards,
|
||||||
|
|
||||||
SetNodeName(Option<String>),
|
SetNodeName(Option<String>),
|
||||||
@ -135,6 +137,7 @@ pub enum Action {
|
|||||||
SetValidatorEraSlash(u32, u128),
|
SetValidatorEraSlash(u32, u128),
|
||||||
SetValidatorEraUnlocking(u32, u128, [u8; 32]),
|
SetValidatorEraUnlocking(u32, u128, [u8; 32]),
|
||||||
SetValidatorLatestClaim(u32, [u8; 32]),
|
SetValidatorLatestClaim(u32, [u8; 32]),
|
||||||
|
SetValidatorInSession(bool, [u8; 32]),
|
||||||
SetIsBonded(bool),
|
SetIsBonded(bool),
|
||||||
SetStakedAmountRatio(u128, u128, [u8; 32]),
|
SetStakedAmountRatio(u128, u128, [u8; 32]),
|
||||||
SetStakedRatio(u128, u128, [u8; 32]),
|
SetStakedRatio(u128, u128, [u8; 32]),
|
||||||
|
@ -24,6 +24,7 @@ pub struct RewardDetails {
|
|||||||
stash: [u8; 32],
|
stash: [u8; 32],
|
||||||
in_staking_validators: bool,
|
in_staking_validators: bool,
|
||||||
in_session_validators: bool,
|
in_session_validators: bool,
|
||||||
|
is_disabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for RewardDetails {
|
impl Default for RewardDetails {
|
||||||
@ -43,6 +44,7 @@ impl RewardDetails {
|
|||||||
stash: [0u8; 32],
|
stash: [0u8; 32],
|
||||||
in_staking_validators: false,
|
in_staking_validators: false,
|
||||||
in_session_validators: false,
|
in_session_validators: false,
|
||||||
|
is_disabled: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,6 +81,13 @@ 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
|
||||||
|
.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();
|
||||||
@ -95,11 +104,15 @@ 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 = match (self.in_staking_validators, self.in_session_validators) {
|
let staking_status = if self.is_disabled {
|
||||||
|
"Staking status: Disabled".to_string()
|
||||||
|
} else {
|
||||||
|
match (self.in_staking_validators, self.in_session_validators) {
|
||||||
(false, false) => "Staking status: Nothing".to_string(),
|
(false, false) => "Staking status: Nothing".to_string(),
|
||||||
(true, false) => "Staking status: Active".to_string(),
|
(true, false) => "Staking status: Stopping".to_string(),
|
||||||
(false, true) => "Staking status: Pending".to_string(),
|
(false, true) => "Staking status: Pending".to_string(),
|
||||||
(true, true) => "Staking status: Active".to_string(),
|
(true, true) => "Staking status: Active".to_string(),
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let table = Table::new(
|
let table = Table::new(
|
||||||
|
@ -159,6 +159,8 @@ impl StashInfo {
|
|||||||
let _ = network_tx.send(Action::GetSessionKeys(account_id, true));
|
let _ = network_tx.send(Action::GetSessionKeys(account_id, true));
|
||||||
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::GetValidatorInSession(account_id, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +118,7 @@ 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?;
|
||||||
@ -206,6 +207,10 @@ 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
|
||||||
|
@ -574,3 +574,18 @@ 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