mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 23:51:05 +00:00
EPM and staking events improvement (#13035)
* EPM and staking events improvement * Uses RawOrigin in ElectionCompute event * Refactors new phase events to PhaseTransition event * PhaseTransitioned and remove RawOrigin from event * Adds helpers for epm phase transition and staking force new * addresses review comments * nit: removes unecessary clone * fixes benchmarks Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -339,7 +339,7 @@ impl<T: Config> Pallet<T> {
|
||||
if maybe_new_era_validators.is_some() &&
|
||||
matches!(ForceEra::<T>::get(), Forcing::ForceNew)
|
||||
{
|
||||
ForceEra::<T>::put(Forcing::NotForcing);
|
||||
Self::set_force_era(Forcing::NotForcing);
|
||||
}
|
||||
|
||||
maybe_new_era_validators
|
||||
@@ -717,11 +717,18 @@ impl<T: Config> Pallet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper to set a new `ForceEra` mode.
|
||||
pub(crate) fn set_force_era(mode: Forcing) {
|
||||
log!(info, "Setting force era mode {:?}.", mode);
|
||||
ForceEra::<T>::put(mode);
|
||||
Self::deposit_event(Event::<T>::ForceEra { mode });
|
||||
}
|
||||
|
||||
/// Ensures that at the end of the current session there will be a new era.
|
||||
pub(crate) fn ensure_new_era() {
|
||||
match ForceEra::<T>::get() {
|
||||
Forcing::ForceAlways | Forcing::ForceNew => (),
|
||||
_ => ForceEra::<T>::put(Forcing::ForceNew),
|
||||
_ => Self::set_force_era(Forcing::ForceNew),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -714,6 +714,8 @@ pub mod pallet {
|
||||
PayoutStarted { era_index: EraIndex, validator_stash: T::AccountId },
|
||||
/// A validator has set their preferences.
|
||||
ValidatorPrefsSet { stash: T::AccountId, prefs: ValidatorPrefs },
|
||||
/// A new force era mode was set.
|
||||
ForceEra { mode: Forcing },
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
@@ -1377,7 +1379,7 @@ pub mod pallet {
|
||||
#[pallet::weight(T::WeightInfo::force_no_eras())]
|
||||
pub fn force_no_eras(origin: OriginFor<T>) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
ForceEra::<T>::put(Forcing::ForceNone);
|
||||
Self::set_force_era(Forcing::ForceNone);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1401,7 +1403,7 @@ pub mod pallet {
|
||||
#[pallet::weight(T::WeightInfo::force_new_era())]
|
||||
pub fn force_new_era(origin: OriginFor<T>) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
ForceEra::<T>::put(Forcing::ForceNew);
|
||||
Self::set_force_era(Forcing::ForceNew);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1452,7 +1454,7 @@ pub mod pallet {
|
||||
#[pallet::weight(T::WeightInfo::force_new_era_always())]
|
||||
pub fn force_new_era_always(origin: OriginFor<T>) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
ForceEra::<T>::put(Forcing::ForceAlways);
|
||||
Self::set_force_era(Forcing::ForceAlways);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user