remove OnStakerSlash replace with OnStakingEvents (#14527)

* remove 'OnStakerSlash', replace with 'OnStakingEvents'

* fix other features in pallets

* small fixes

* fix docs

* fix docs

* fix docs

* Update primitives/staking/src/lib.rs

Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com>

---------

Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com>
This commit is contained in:
Kian Paimani
2023-07-09 14:46:18 +02:00
committed by GitHub
parent 53244d64bd
commit 6dd625d568
28 changed files with 261 additions and 177 deletions
+3 -4
View File
@@ -314,7 +314,7 @@ use sp_runtime::{
pub use sp_staking::StakerStatus;
use sp_staking::{
offence::{Offence, OffenceError, ReportOffence},
EraIndex, SessionIndex,
EraIndex, OnStakingUpdate, SessionIndex,
};
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
pub use weights::WeightInfo;
@@ -549,7 +549,7 @@ impl<T: Config> StakingLedger<T> {
///
/// `slash_era` is the era in which the slash (which is being enacted now) actually happened.
///
/// This calls `Config::OnStakerSlash::on_slash` with information as to how the slash was
/// This calls `Config::OnStakingUpdate::on_slash` with information as to how the slash was
/// applied.
pub fn slash(
&mut self,
@@ -562,7 +562,6 @@ impl<T: Config> StakingLedger<T> {
}
use sp_runtime::PerThing as _;
use sp_staking::OnStakerSlash as _;
let mut remaining_slash = slash_amount;
let pre_slash_total = self.total;
@@ -667,7 +666,7 @@ impl<T: Config> StakingLedger<T> {
// clean unlocking chunks that are set to zero.
self.unlocking.retain(|c| !c.value.is_zero());
T::OnStakerSlash::on_slash(&self.stash, self.active, &slashed_unlocking);
T::EventListeners::on_slash(&self.stash, self.active, &slashed_unlocking);
pre_slash_total.saturating_sub(self.total)
}
}