INNER CODE UNIT · Rust

slash_non_candidate

AstarNetwork/Astar · pallets/collator-selection/src/lib.rs:732

        fn slash_non_candidate(who: &T::AccountId) {
            NonCandidates::<T>::mutate_exists(who, |maybe| {
                if let Some((_index, deposit)) = maybe.take() {
                    let slash = T::SlashRatio::get() * deposit;
                    let remain = deposit.saturating_sub(slash);

                    let (imbalance, _) = T::Currency::slash_reserved(who, slash);
                    T::Currency::unreserve(who, remain);

                    if let Some(dest) = SlashDestination::<T>::get() {
                        T::Currency::resolve_creating(&dest, imbalance);
                    }

                    <LastAuthoredBlock<T>>::remove(who);

                    Self::deposit_event(Event::CandidateSlashed(who.clone()));
                }
            });

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…