From 9bdb7b5d5c70e952bf99d2df96f0bc89fa484e8d Mon Sep 17 00:00:00 2001 From: Uncle Stinky Date: Thu, 31 Jul 2025 14:02:14 +0300 Subject: [PATCH] add an early check for the disabled validator Signed-off-by: Uncle Stinky --- pallets/slow-clap/Cargo.toml | 2 +- pallets/slow-clap/src/lib.rs | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/pallets/slow-clap/Cargo.toml b/pallets/slow-clap/Cargo.toml index 177628c..fbfccb4 100644 --- a/pallets/slow-clap/Cargo.toml +++ b/pallets/slow-clap/Cargo.toml @@ -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 diff --git a/pallets/slow-clap/src/lib.rs b/pallets/slow-clap/src/lib.rs index bfa9755..7c0d046 100644 --- a/pallets/slow-clap/src/lib.rs +++ b/pallets/slow-clap/src/lib.rs @@ -465,6 +465,13 @@ impl Pallet { authorities.get(clap.authority_index as usize).is_some(), Error::::NotAnAuthority ); + ensure!( + ClapsInSession::::get(&clap.session_index) + .get(&clap.authority_index) + .map(|info| !info.disabled) + .unwrap_or(true), + Error::::CurrentValidatorIsDisabled + ); let clap_unique_hash = Self::generate_unique_hash(&clap.receiver, &clap.amount, &clap.network_id); @@ -491,15 +498,7 @@ impl Pallet { } })?; - ClapsInSession::::try_mutate(&clap.session_index, |claps_details| { - if claps_details - .get(&clap.authority_index) - .map(|x| x.disabled) - .unwrap_or_default() - { - return Err(Error::::CurrentValidatorIsDisabled); - } - + ClapsInSession::::mutate(&clap.session_index, |claps_details| { (*claps_details) .entry(clap.authority_index) .and_modify(|individual| (*individual).claps.saturating_inc()) @@ -507,9 +506,7 @@ impl Pallet { claps: 1u32, disabled: false, }); - - Ok(()) - })?; + }); Self::deposit_event(Event::::Clapped { authority_id: clap.authority_index,