optimize offenders gathering with a single pass over the data
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
parent
46aa18aafe
commit
7edc8935b6
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ghost-slow-clap"
|
||||
version = "0.3.41"
|
||||
version = "0.3.42"
|
||||
description = "Applause protocol for the EVM bridge"
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
|
||||
@ -1123,11 +1123,13 @@ impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
|
||||
let offenders = validators
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.filter(|(index, _)| !Self::is_good_actor(*index, median_claps, &claps_in_session))
|
||||
.filter_map(|(_, id)| {
|
||||
<T::ValidatorSet as ValidatorSetWithIdentification<T::AccountId>>::IdentificationOf::convert(
|
||||
id.clone(),
|
||||
).map(|full_id| (id, full_id))
|
||||
.filter_map(|(index, id)| {
|
||||
(!Self::is_good_actor(index, median_claps, &claps_in_session)).then(|| {
|
||||
<T::ValidatorSet as ValidatorSetWithIdentification<T::AccountId>>::IdentificationOf::convert(
|
||||
id.clone(),
|
||||
).map(|full_id| (id, full_id))
|
||||
})
|
||||
.flatten()
|
||||
})
|
||||
.collect::<Vec<IdentificationTuple<T>>>();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user