Print only unique doppelgangers (#2500)

## Issue Addressed

N/A

## Proposed Changes

This is just a cosmetic change to print only the unique list of violaters. We could repeat violaters in the list if an attestation and aggregation both were detected from the same validator.
This commit is contained in:
Pawan Dhananjay 2021-08-05 22:27:40 +00:00
parent fc8969302c
commit 350b6f19de

View File

@ -36,7 +36,7 @@ use eth2::types::LivenessResponseData;
use parking_lot::RwLock;
use slog::{crit, error, info, Logger};
use slot_clock::SlotClock;
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use std::future::Future;
use std::sync::Arc;
use task_executor::ShutdownReason;
@ -505,7 +505,7 @@ impl DoppelgangerService {
//
// A following loop will update the states of each validator, depending on whether or not
// any violators were detected here.
let mut violators = vec![];
let mut violators = HashSet::new();
for response in previous_epoch_responses
.iter()
.chain(current_epoch_responses.iter())
@ -541,7 +541,7 @@ impl DoppelgangerService {
};
if response.is_live && next_check_epoch <= response.epoch {
violators.push(response.index);
violators.insert(response.index);
}
}