INNER CODE UNIT · Rust
kick_stale_candidates
AstarNetwork/Astar · pallets/collator-selection/src/lib.rs:762
pub fn kick_stale_candidates() -> (u32, u32) {
let now = frame_system::Pallet::<T>::block_number();
let kick_threshold = T::KickThreshold::get();
let count = Candidates::<T>::get().len() as u32;
for (who, last_authored) in LastAuthoredBlock::<T>::iter() {
if now.saturating_sub(last_authored) < kick_threshold {
continue;
}
// stale candidate, kick and slash
if Self::is_account_candidate(&who) {
if Candidates::<T>::get().len() > T::MinCandidates::get() as usize {
// no error, who is a candidate
let _ = Self::try_remove_candidate(&who);
Self::slash_non_candidate(&who);
}
} else if let Some((locked_until, _)) = NonCandidates::<T>::get(&who) {
if T::ValidatorSet::session_index() > locked_until {
// bond is already unlocked