add an early check for the disabled validator

Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
Uncle Stinky
2025-07-31 14:02:14 +03:00
parent c4b16805f7
commit 9bdb7b5d5c
2 changed files with 10 additions and 13 deletions

View File

@@ -465,6 +465,13 @@ impl<T: Config> Pallet<T> {
authorities.get(clap.authority_index as usize).is_some(),
Error::<T>::NotAnAuthority
);
ensure!(
ClapsInSession::<T>::get(&clap.session_index)
.get(&clap.authority_index)
.map(|info| !info.disabled)
.unwrap_or(true),
Error::<T>::CurrentValidatorIsDisabled
);
let clap_unique_hash =
Self::generate_unique_hash(&clap.receiver, &clap.amount, &clap.network_id);
@@ -491,15 +498,7 @@ impl<T: Config> Pallet<T> {
}
})?;
ClapsInSession::<T>::try_mutate(&clap.session_index, |claps_details| {
if claps_details
.get(&clap.authority_index)
.map(|x| x.disabled)
.unwrap_or_default()
{
return Err(Error::<T>::CurrentValidatorIsDisabled);
}
ClapsInSession::<T>::mutate(&clap.session_index, |claps_details| {
(*claps_details)
.entry(clap.authority_index)
.and_modify(|individual| (*individual).claps.saturating_inc())
@@ -507,9 +506,7 @@ impl<T: Config> Pallet<T> {
claps: 1u32,
disabled: false,
});
Ok(())
})?;
});
Self::deposit_event(Event::<T>::Clapped {
authority_id: clap.authority_index,