mirror of
https://git.ghostchain.io/proxmio/ghost-node.git
synced 2025-12-27 03:09:56 +00:00
add an early check for the disabled validator
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user