mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 15:11:03 +00:00
Add Chilled event to staking chill extrinsics (#9250)
* Add `Chilled` event to staking chill extrinsics
* Update do_remove_{nom, val} doc comments
* Not working: trying to match on event
* Account for chilled event in offences benchmarking
* trigger ci
* correct
This commit is contained in:
@@ -1329,6 +1329,9 @@ pub mod pallet {
|
||||
Kicked(T::AccountId, T::AccountId),
|
||||
/// The election failed. No new era is planned.
|
||||
StakingElectionFailed,
|
||||
/// An account has stopped participating as either a validator or nominator.
|
||||
/// \[stash\]
|
||||
Chilled(T::AccountId),
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
@@ -2523,8 +2526,11 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
/// Chill a stash account.
|
||||
fn chill_stash(stash: &T::AccountId) {
|
||||
Self::do_remove_validator(stash);
|
||||
Self::do_remove_nominator(stash);
|
||||
let chilled_as_validator = Self::do_remove_validator(stash);
|
||||
let chilled_as_nominator = Self::do_remove_nominator(stash);
|
||||
if chilled_as_validator || chilled_as_nominator {
|
||||
Self::deposit_event(Event::<T>::Chilled(stash.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
/// Actually make a payment to a staker. This uses the currency's reward function
|
||||
@@ -3014,10 +3020,15 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
/// This function will remove a nominator from the `Nominators` storage map,
|
||||
/// and keep track of the `CounterForNominators`.
|
||||
pub fn do_remove_nominator(who: &T::AccountId) {
|
||||
///
|
||||
/// Returns true if `who` was removed from `Nominators`, otherwise false.
|
||||
pub fn do_remove_nominator(who: &T::AccountId) -> bool {
|
||||
if Nominators::<T>::contains_key(who) {
|
||||
Nominators::<T>::remove(who);
|
||||
CounterForNominators::<T>::mutate(|x| x.saturating_dec());
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3034,10 +3045,15 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
/// This function will remove a validator from the `Validators` storage map,
|
||||
/// and keep track of the `CounterForValidators`.
|
||||
pub fn do_remove_validator(who: &T::AccountId) {
|
||||
///
|
||||
/// Returns true if `who` was removed from `Validators`, otherwise false.
|
||||
pub fn do_remove_validator(who: &T::AccountId) -> bool {
|
||||
if Validators::<T>::contains_key(who) {
|
||||
Validators::<T>::remove(who);
|
||||
CounterForValidators::<T>::mutate(|x| x.saturating_dec());
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user