INNER CODE UNIT · Rust
remove_invulnerable
AstarNetwork/Astar · pallets/collator-selection/src/lib.rs:516
pub fn remove_invulnerable(
origin: OriginFor<T>,
who: T::AccountId,
) -> DispatchResultWithPostInfo {
T::UpdateOrigin::ensure_origin(origin)?;
<Invulnerables<T>>::try_mutate(|invulnerables| -> DispatchResult {
if let Some(pos) = invulnerables.iter().position(|acc| *acc == who) {
invulnerables.remove(pos);
Ok(())
} else {
Err(Error::<T>::NotInvulnerable.into())
}
})?;
Self::deposit_event(Event::NewInvulnerables(<Invulnerables<T>>::get()));
Ok(().into())
}