Compare commits
7 Commits
5e90456fdf
...
d42bb97d36
Author | SHA1 | Date | |
---|---|---|---|
d42bb97d36 | |||
c4f0f6f35c | |||
e16d319b72 | |||
2635792dab | |||
33027f96d5 | |||
9dad47210b | |||
22db763d31 |
@ -2,8 +2,10 @@
|
|||||||
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.34"
|
version = "0.3.40"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
homepage = "https://git.ghostchain.io/ghostchain"
|
||||||
|
repository = "https://git.ghostchain.io/ghostchain/ghost-eye"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
better-panic = "0.3.0"
|
better-panic = "0.3.0"
|
||||||
|
@ -104,6 +104,7 @@ pub enum Action {
|
|||||||
GetErasStakersOverview([u8; 32], bool),
|
GetErasStakersOverview([u8; 32], bool),
|
||||||
GetValidatorPrefs([u8; 32], bool),
|
GetValidatorPrefs([u8; 32], bool),
|
||||||
GetSlashingSpans([u8; 32], bool),
|
GetSlashingSpans([u8; 32], bool),
|
||||||
|
GetValidatorLatestClaim([u8; 32], bool),
|
||||||
GetCurrentValidatorEraRewards,
|
GetCurrentValidatorEraRewards,
|
||||||
|
|
||||||
SetNodeName(Option<String>),
|
SetNodeName(Option<String>),
|
||||||
@ -133,6 +134,7 @@ pub enum Action {
|
|||||||
SetValidatorEraClaimed(u32, bool),
|
SetValidatorEraClaimed(u32, bool),
|
||||||
SetValidatorEraSlash(u32, u128),
|
SetValidatorEraSlash(u32, u128),
|
||||||
SetValidatorEraUnlocking(u32, u128, [u8; 32]),
|
SetValidatorEraUnlocking(u32, u128, [u8; 32]),
|
||||||
|
SetValidatorLatestClaim(u32, [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]),
|
||||||
|
@ -23,6 +23,7 @@ pub struct CurrentValidatorDetails {
|
|||||||
others_len: usize,
|
others_len: usize,
|
||||||
commission: f64,
|
commission: f64,
|
||||||
points_ratio: f64,
|
points_ratio: f64,
|
||||||
|
latest_era_claim: u32,
|
||||||
is_active_validator: bool,
|
is_active_validator: bool,
|
||||||
is_nomination_disabled: bool,
|
is_nomination_disabled: bool,
|
||||||
}
|
}
|
||||||
@ -49,6 +50,7 @@ impl CurrentValidatorDetails {
|
|||||||
commission: 0.0,
|
commission: 0.0,
|
||||||
points_ratio: 0.0,
|
points_ratio: 0.0,
|
||||||
palette: Default::default(),
|
palette: Default::default(),
|
||||||
|
latest_era_claim: 0,
|
||||||
is_active_validator: false,
|
is_active_validator: false,
|
||||||
is_nomination_disabled: false,
|
is_nomination_disabled: false,
|
||||||
}
|
}
|
||||||
@ -92,16 +94,20 @@ impl CurrentValidatorDetails {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn update_choosen_validator(&mut self, account_id: [u8; 32], individual: u32, total: u32) {
|
fn update_choosen_validator(&mut self, account_id: [u8; 32], individual: u32, total: u32) {
|
||||||
self.choosen = account_id;
|
|
||||||
self.points_ratio = match total {
|
self.points_ratio = match total {
|
||||||
0 => 0.0,
|
0 => 0.0,
|
||||||
_ => individual as f64 / total as f64,
|
_ => (individual as f64 / total as f64) * 100.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if self.choosen != account_id {
|
||||||
|
self.choosen = account_id;
|
||||||
if let Some(network_tx) = &self.network_tx {
|
if let Some(network_tx) = &self.network_tx {
|
||||||
let _ = network_tx.send(Action::GetErasStakersOverview(account_id, false));
|
let _ = network_tx.send(Action::GetErasStakersOverview(account_id, false));
|
||||||
let _ = network_tx.send(Action::GetNominatorsByValidator(account_id, false));
|
let _ = network_tx.send(Action::GetNominatorsByValidator(account_id, false));
|
||||||
let _ = network_tx.send(Action::GetValidatorPrefs(account_id, false));
|
let _ = network_tx.send(Action::GetValidatorPrefs(account_id, false));
|
||||||
let _ = network_tx.send(Action::GetValidatorLedger(account_id, false));
|
let _ = network_tx.send(Action::GetValidatorLedger(account_id, false));
|
||||||
|
let _ = network_tx.send(Action::GetValidatorLatestClaim(account_id, false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,10 +142,12 @@ impl Component for CurrentValidatorDetails {
|
|||||||
Action::SetValidatorPrefs(commission, is_disabled, account_id) if self.choosen == account_id => self.update_commission(commission, is_disabled),
|
Action::SetValidatorPrefs(commission, is_disabled, account_id) if self.choosen == account_id => self.update_commission(commission, is_disabled),
|
||||||
Action::SetNominatorsByValidator(noms, account_id) if self.choosen == account_id => self.others_len = noms.len(),
|
Action::SetNominatorsByValidator(noms, account_id) if self.choosen == account_id => self.others_len = noms.len(),
|
||||||
Action::SetStakedAmountRatio(_, active_stake, account_id) if self.choosen == account_id => self.active_stake = active_stake,
|
Action::SetStakedAmountRatio(_, active_stake, account_id) if self.choosen == account_id => self.active_stake = active_stake,
|
||||||
|
Action::SetValidatorLatestClaim(era_index, account_id) if self.choosen == account_id => self.latest_era_claim = era_index,
|
||||||
Action::SetStakedRatio(total, own, account_id) if self.choosen == account_id => {
|
Action::SetStakedRatio(total, own, account_id) if self.choosen == account_id => {
|
||||||
self.total_balance = total;
|
self.total_balance = total;
|
||||||
self.own_balance = own;
|
self.own_balance = own;
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
Ok(None)
|
Ok(None)
|
||||||
@ -183,6 +191,10 @@ impl Component for CurrentValidatorDetails {
|
|||||||
Cell::from(Text::from("Imbalance".to_string()).alignment(Alignment::Left)),
|
Cell::from(Text::from("Imbalance".to_string()).alignment(Alignment::Left)),
|
||||||
Cell::from(Text::from(self.prepare_stake_imbalance()).alignment(Alignment::Right)),
|
Cell::from(Text::from(self.prepare_stake_imbalance()).alignment(Alignment::Right)),
|
||||||
]),
|
]),
|
||||||
|
Row::new(vec![
|
||||||
|
Cell::from(Text::from("Last payout".to_string()).alignment(Alignment::Left)),
|
||||||
|
Cell::from(Text::from(format!("{} days ago", self.latest_era_claim)).alignment(Alignment::Right)),
|
||||||
|
]),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Constraint::Max(12),
|
Constraint::Max(12),
|
||||||
|
@ -34,7 +34,6 @@ pub struct CurrentValidators {
|
|||||||
table_state: TableState,
|
table_state: TableState,
|
||||||
individual: Vec<EraRewardPoints>,
|
individual: Vec<EraRewardPoints>,
|
||||||
known_validators: std::collections::HashMap<[u8; 32], String>,
|
known_validators: std::collections::HashMap<[u8; 32], String>,
|
||||||
active_validators: std::collections::HashSet<String>,
|
|
||||||
total_points: u32,
|
total_points: u32,
|
||||||
era_index: u32,
|
era_index: u32,
|
||||||
my_stash_id: Option<[u8; 32]>,
|
my_stash_id: Option<[u8; 32]>,
|
||||||
@ -58,7 +57,6 @@ impl CurrentValidators {
|
|||||||
table_state: TableState::new(),
|
table_state: TableState::new(),
|
||||||
individual: Default::default(),
|
individual: Default::default(),
|
||||||
known_validators: Default::default(),
|
known_validators: Default::default(),
|
||||||
active_validators: Default::default(),
|
|
||||||
total_points: 0,
|
total_points: 0,
|
||||||
era_index: 0,
|
era_index: 0,
|
||||||
my_stash_id: None,
|
my_stash_id: None,
|
||||||
@ -68,9 +66,14 @@ impl CurrentValidators {
|
|||||||
|
|
||||||
fn update_choosen_details(&self, index: usize) {
|
fn update_choosen_details(&self, index: usize) {
|
||||||
if let Some(action_tx) = &self.action_tx {
|
if let Some(action_tx) = &self.action_tx {
|
||||||
|
let (selected_account_id, selected_points) = self.individual
|
||||||
|
.get(index)
|
||||||
|
.map(|data| (data.account_id, data.points))
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
let _ = action_tx.send(Action::SetChoosenValidator(
|
let _ = action_tx.send(Action::SetChoosenValidator(
|
||||||
self.individual[index].account_id,
|
selected_account_id,
|
||||||
self.individual[index].points,
|
selected_points,
|
||||||
self.total_points));
|
self.total_points));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,13 +188,13 @@ impl CurrentValidators {
|
|||||||
.position(|item| item.account_id == account_id) {
|
.position(|item| item.account_id == account_id) {
|
||||||
self.individual.swap(0, index);
|
self.individual.swap(0, index);
|
||||||
}
|
}
|
||||||
|
let current_index = self.table_state.selected().unwrap_or_default();
|
||||||
|
self.table_state.select(Some(current_index));
|
||||||
|
self.update_choosen_details(current_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.scroll_state = self.scroll_state.content_length(self.individual.len());
|
self.scroll_state = self.scroll_state.content_length(self.individual.len());
|
||||||
if let Some(index) = self.table_state.selected() {
|
|
||||||
self.update_choosen_details(index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +270,6 @@ impl Component for CurrentValidators {
|
|||||||
if info.disabled {
|
if info.disabled {
|
||||||
address_text = address_text.add_modifier(Modifier::CROSSED_OUT);
|
address_text = address_text.add_modifier(Modifier::CROSSED_OUT);
|
||||||
points_text = points_text.add_modifier(Modifier::CROSSED_OUT);
|
points_text = points_text.add_modifier(Modifier::CROSSED_OUT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut current_validator_is_my_stash = false;
|
let mut current_validator_is_my_stash = false;
|
||||||
|
@ -116,15 +116,15 @@ impl Validator {
|
|||||||
CurrentTab::Peers => self.current_tab = CurrentTab::Withdrawals,
|
CurrentTab::Peers => self.current_tab = CurrentTab::Withdrawals,
|
||||||
CurrentTab::Withdrawals => self.current_tab = CurrentTab::History,
|
CurrentTab::Withdrawals => self.current_tab = CurrentTab::History,
|
||||||
CurrentTab::History => self.current_tab = CurrentTab::NominatorsByValidator,
|
CurrentTab::History => self.current_tab = CurrentTab::NominatorsByValidator,
|
||||||
CurrentTab::NominatorsByValidator => self.current_tab = CurrentTab::ListenAddresses,
|
CurrentTab::ListenAddresses => self.current_tab = CurrentTab::NominatorsByValidator,
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_right(&mut self) {
|
fn move_right(&mut self) {
|
||||||
match self.current_tab {
|
match self.current_tab {
|
||||||
CurrentTab::Nothing => self.current_tab = CurrentTab::ListenAddresses,
|
|
||||||
CurrentTab::ListenAddresses => self.current_tab = CurrentTab::NominatorsByValidator,
|
CurrentTab::ListenAddresses => self.current_tab = CurrentTab::NominatorsByValidator,
|
||||||
|
CurrentTab::Nothing => self.current_tab = CurrentTab::NominatorsByValidator,
|
||||||
CurrentTab::NominatorsByValidator => self.current_tab = CurrentTab::History,
|
CurrentTab::NominatorsByValidator => self.current_tab = CurrentTab::History,
|
||||||
CurrentTab::History => self.current_tab = CurrentTab::Withdrawals,
|
CurrentTab::History => self.current_tab = CurrentTab::Withdrawals,
|
||||||
CurrentTab::Withdrawals => self.current_tab = CurrentTab::Peers,
|
CurrentTab::Withdrawals => self.current_tab = CurrentTab::Peers,
|
||||||
@ -250,6 +250,13 @@ impl Component for Validator {
|
|||||||
component.set_active(self.current_tab.clone());
|
component.set_active(self.current_tab.clone());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
KeyCode::Char('L') => {
|
||||||
|
self.previous_tab = self.current_tab;
|
||||||
|
self.current_tab = CurrentTab::ListenAddresses;
|
||||||
|
for component in self.components.iter_mut() {
|
||||||
|
component.set_active(self.current_tab.clone());
|
||||||
|
}
|
||||||
|
},
|
||||||
_ => {
|
_ => {
|
||||||
for component in self.components.iter_mut() {
|
for component in self.components.iter_mut() {
|
||||||
component.handle_key_event(key)?;
|
component.handle_key_event(key)?;
|
||||||
@ -264,7 +271,7 @@ impl Component for Validator {
|
|||||||
match action {
|
match action {
|
||||||
Action::SetActiveScreen(Mode::Validator) => {
|
Action::SetActiveScreen(Mode::Validator) => {
|
||||||
self.is_active = true;
|
self.is_active = true;
|
||||||
self.current_tab = CurrentTab::ListenAddresses;
|
self.current_tab = CurrentTab::NominatorsByValidator;
|
||||||
}
|
}
|
||||||
Action::PayoutValidatorPopup(_, _) => {
|
Action::PayoutValidatorPopup(_, _) => {
|
||||||
self.previous_tab = self.current_tab;
|
self.previous_tab = self.current_tab;
|
||||||
|
@ -22,6 +22,8 @@ pub struct RewardDetails {
|
|||||||
apy: String,
|
apy: String,
|
||||||
inflation: String,
|
inflation: String,
|
||||||
stash: [u8; 32],
|
stash: [u8; 32],
|
||||||
|
in_staking_validators: bool,
|
||||||
|
in_session_validators: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for RewardDetails {
|
impl Default for RewardDetails {
|
||||||
@ -39,6 +41,8 @@ impl RewardDetails {
|
|||||||
apy: String::from("0.0%"),
|
apy: String::from("0.0%"),
|
||||||
inflation: String::from("0.0%"),
|
inflation: String::from("0.0%"),
|
||||||
stash: [0u8; 32],
|
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::SetStashAccount(stash) => self.stash = stash,
|
||||||
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.nominators_blocked = disabled;
|
self.nominators_blocked = disabled;
|
||||||
}
|
}
|
||||||
Action::Apy(apy) => self.apy = apy,
|
Action::Apy(apy) => self.apy = apy,
|
||||||
@ -90,6 +95,13 @@ 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) {
|
||||||
|
(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(
|
let table = Table::new(
|
||||||
vec![
|
vec![
|
||||||
Row::new(vec![
|
Row::new(vec![
|
||||||
@ -117,7 +129,7 @@ impl Component for RewardDetails {
|
|||||||
.border_type(border_type)
|
.border_type(border_type)
|
||||||
.title_alignment(Alignment::Right)
|
.title_alignment(Alignment::Right)
|
||||||
.title_style(self.palette.create_title_style(false))
|
.title_style(self.palette.create_title_style(false))
|
||||||
.title("Reward details"));
|
.title(staking_status));
|
||||||
|
|
||||||
frame.render_widget(table, place);
|
frame.render_widget(table, place);
|
||||||
|
|
||||||
|
@ -127,6 +127,7 @@ impl Network {
|
|||||||
predefined_calls::get_nominators_by_validator(&self.action_tx, &self.online_client_api, &validator_details_to_watch).await?;
|
predefined_calls::get_nominators_by_validator(&self.action_tx, &self.online_client_api, &validator_details_to_watch).await?;
|
||||||
predefined_calls::get_validator_prefs(&self.action_tx, &self.online_client_api, &validator_details_to_watch).await?;
|
predefined_calls::get_validator_prefs(&self.action_tx, &self.online_client_api, &validator_details_to_watch).await?;
|
||||||
predefined_calls::get_staking_value_ratio(&self.action_tx, &self.online_client_api, &validator_details_to_watch).await?;
|
predefined_calls::get_staking_value_ratio(&self.action_tx, &self.online_client_api, &validator_details_to_watch).await?;
|
||||||
|
predefined_calls::get_validator_latest_claim(&self.action_tx, &self.online_client_api, &validator_details_to_watch).await?;
|
||||||
}
|
}
|
||||||
for account_id in self.accounts_to_watch.iter() {
|
for account_id in self.accounts_to_watch.iter() {
|
||||||
predefined_calls::get_balance(&self.action_tx, &self.online_client_api, &account_id).await?;
|
predefined_calls::get_balance(&self.action_tx, &self.online_client_api, &account_id).await?;
|
||||||
@ -205,6 +206,10 @@ impl Network {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Action::GetValidatorLatestClaim(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
|
||||||
|
}
|
||||||
Action::GetSlashingSpans(account_id, is_stash) => {
|
Action::GetSlashingSpans(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_slashing_spans(&self.action_tx, &self.online_client_api, &account_id).await
|
predefined_calls::get_slashing_spans(&self.action_tx, &self.online_client_api, &account_id).await
|
||||||
|
@ -284,7 +284,9 @@ pub async fn get_validator_staking_results(
|
|||||||
let current_era = super::raw_calls::staking::current_era(api, None).await?.unwrap_or(0);
|
let current_era = super::raw_calls::staking::current_era(api, None).await?.unwrap_or(0);
|
||||||
let era_depth = super::raw_calls::staking::history_depth(api).unwrap_or(0);
|
let era_depth = super::raw_calls::staking::history_depth(api).unwrap_or(0);
|
||||||
for era_index in current_era.saturating_sub(era_depth)..current_era {
|
for era_index in current_era.saturating_sub(era_depth)..current_era {
|
||||||
get_validator_staking_result(action_tx, api, account_id, era_index).await?;
|
if get_validator_staking_result(action_tx, api, account_id, era_index).await? {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -294,11 +296,11 @@ pub async fn get_validator_staking_result(
|
|||||||
api: &OnlineClient<CasperConfig>,
|
api: &OnlineClient<CasperConfig>,
|
||||||
account_id: &[u8; 32],
|
account_id: &[u8; 32],
|
||||||
era_index: u32,
|
era_index: u32,
|
||||||
) -> Result<()> {
|
) -> Result<bool> {
|
||||||
get_validator_reward_in_era(action_tx, api, account_id, era_index).await?;
|
let no_more_rewards = get_validator_reward_in_era(action_tx, api, account_id, era_index).await?;
|
||||||
get_validator_claims_in_era(action_tx, api, account_id, era_index).await?;
|
get_validator_claims_in_era(action_tx, api, account_id, era_index).await?;
|
||||||
get_validator_slashes_in_era(action_tx, api, account_id, era_index).await?;
|
get_validator_slashes_in_era(action_tx, api, account_id, era_index).await?;
|
||||||
Ok(())
|
Ok(no_more_rewards)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_current_validator_reward_in_era(
|
pub async fn get_current_validator_reward_in_era(
|
||||||
@ -351,13 +353,9 @@ async fn get_validator_reward_in_era(
|
|||||||
api: &OnlineClient<CasperConfig>,
|
api: &OnlineClient<CasperConfig>,
|
||||||
account_id: &[u8; 32],
|
account_id: &[u8; 32],
|
||||||
era_index: u32,
|
era_index: u32,
|
||||||
) -> Result<()> {
|
) -> Result<bool> {
|
||||||
let maybe_era_reward_points = super::raw_calls::staking::eras_reward_points(api, None, era_index)
|
let maybe_era_reward_points = super::raw_calls::staking::eras_reward_points(api, None, era_index).await?;
|
||||||
.await?;
|
let era_reward = super::raw_calls::staking::eras_validator_reward(api, None, era_index).await?.unwrap_or_default();
|
||||||
|
|
||||||
let era_reward = super::raw_calls::staking::eras_validator_reward(api, None, era_index)
|
|
||||||
.await?
|
|
||||||
.unwrap_or_default();
|
|
||||||
|
|
||||||
let my_reward = match maybe_era_reward_points {
|
let my_reward = match maybe_era_reward_points {
|
||||||
Some(era_reward_points) => {
|
Some(era_reward_points) => {
|
||||||
@ -373,9 +371,14 @@ async fn get_validator_reward_in_era(
|
|||||||
None => 0u128,
|
None => 0u128,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let no_more_rewards = if my_reward > 0 {
|
||||||
action_tx.send(Action::SetValidatorEraReward(era_index, my_reward))?;
|
action_tx.send(Action::SetValidatorEraReward(era_index, my_reward))?;
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
};
|
||||||
|
|
||||||
Ok(())
|
Ok(no_more_rewards)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_validator_claims_in_era(
|
async fn get_validator_claims_in_era(
|
||||||
@ -534,3 +537,32 @@ pub async fn get_slashing_spans(
|
|||||||
action_tx.send(Action::SetSlashingSpansLength(slashing_spans_length, *account_id))?;
|
action_tx.send(Action::SetSlashingSpansLength(slashing_spans_length, *account_id))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_validator_latest_claim(
|
||||||
|
action_tx: &UnboundedSender<Action>,
|
||||||
|
api: &OnlineClient<CasperConfig>,
|
||||||
|
account_id: &[u8; 32],
|
||||||
|
) -> Result<()> {
|
||||||
|
let current_era = super::raw_calls::staking::current_era(api, None).await?.unwrap_or(0);
|
||||||
|
let era_depth = super::raw_calls::staking::history_depth(api).unwrap_or(0);
|
||||||
|
|
||||||
|
let last_era = current_era.saturating_sub(era_depth);
|
||||||
|
let mut claimed_era = current_era;
|
||||||
|
|
||||||
|
while claimed_era > last_era {
|
||||||
|
let is_claimed = super::raw_calls::staking::claimed_rewards(api, None, claimed_era, account_id)
|
||||||
|
.await?
|
||||||
|
.map(|claimed_rewards| claimed_rewards.len() > 0)
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
if is_claimed {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
claimed_era -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
action_tx.send(Action::SetValidatorLatestClaim(current_era.saturating_sub(claimed_era), *account_id))?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user