Skip to content

Commit bb6904d

Browse files
committed
Remove only non-elected validators
1 parent 2d8ab37 commit bb6904d

File tree

1 file changed

+15
-12
lines changed
  • substrate/frame/staking/src/pallet

1 file changed

+15
-12
lines changed

substrate/frame/staking/src/pallet/impls.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -442,20 +442,23 @@ impl<T: Config> Pallet<T> {
442442
Self::clear_era_information(old_era);
443443
}
444444

445-
let whitelist = Self::candidate_whitelist();
446-
let to_remove: Vec<_> = Validators::<T>::iter_keys()
447-
.filter(|validator| {
448-
whitelist
449-
.as_ref()
450-
.map_or(false, |set| !set.contains(&validator))
451-
})
452-
.collect();
453-
for validator in to_remove {
454-
Self::do_remove_validator(&validator);
445+
// Set staking information for the new era.
446+
let new_validators = Self::store_stakers_info(exposures, new_planned_era);
447+
448+
if let Some(whitelist) = Self::candidate_whitelist() {
449+
let to_remove: Vec<_> = Validators::<T>::iter_keys()
450+
.filter(|validator| {
451+
!whitelist.contains(&validator)
452+
&& !new_validators.iter().any(|active| active == validator)
453+
})
454+
.collect();
455+
456+
for validator in to_remove {
457+
Self::do_remove_validator(&validator);
458+
}
455459
}
456460

457-
// Set staking information for the new era.
458-
Self::store_stakers_info(exposures, new_planned_era)
461+
new_validators
459462
}
460463

461464
/// Potentially plan a new era.

0 commit comments

Comments
 (0)