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
Signed by: st1nky
GPG Key ID: 016064BD97603B40
2 changed files with 10 additions and 13 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "ghost-slow-clap"
version = "0.3.36"
version = "0.3.37"
description = "Applause protocol for the EVM bridge"
license.workspace = true
authors.workspace = true

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,