mirror of
https://git.ghostchain.io/proxmio/ghost-node.git
synced 2025-12-27 11:19:57 +00:00
optimize offenders gathering with a single pass over the data
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
@@ -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>>>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user