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]
|
[package]
|
||||||
name = "ghost-slow-clap"
|
name = "ghost-slow-clap"
|
||||||
version = "0.3.41"
|
version = "0.3.42"
|
||||||
description = "Applause protocol for the EVM bridge"
|
description = "Applause protocol for the EVM bridge"
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
|
|||||||
@ -1123,11 +1123,13 @@ impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
|
|||||||
let offenders = validators
|
let offenders = validators
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter(|(index, _)| !Self::is_good_actor(*index, median_claps, &claps_in_session))
|
.filter_map(|(index, id)| {
|
||||||
.filter_map(|(_, id)| {
|
(!Self::is_good_actor(index, median_claps, &claps_in_session)).then(|| {
|
||||||
<T::ValidatorSet as ValidatorSetWithIdentification<T::AccountId>>::IdentificationOf::convert(
|
<T::ValidatorSet as ValidatorSetWithIdentification<T::AccountId>>::IdentificationOf::convert(
|
||||||
id.clone(),
|
id.clone(),
|
||||||
).map(|full_id| (id, full_id))
|
).map(|full_id| (id, full_id))
|
||||||
|
})
|
||||||
|
.flatten()
|
||||||
})
|
})
|
||||||
.collect::<Vec<IdentificationTuple<T>>>();
|
.collect::<Vec<IdentificationTuple<T>>>();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user