Ensure attestation_participants is deduped

This commit is contained in:
Paul Hauner 2019-01-31 18:31:20 +11:00
parent d6adfc7655
commit e1239a1ecc
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6

View File

@ -18,14 +18,19 @@ impl BeaconState {
attestations: &[&PendingAttestation],
spec: &ChainSpec,
) -> Result<Vec<usize>, Error> {
attestations.iter().try_fold(vec![], |mut acc, a| {
acc.append(&mut self.get_attestation_participants(
&a.data,
&a.aggregation_bitfield,
spec,
)?);
Ok(acc)
})
let mut all_participants = attestations
.iter()
.try_fold::<_, _, Result<Vec<usize>, Error>>(vec![], |mut acc, a| {
acc.append(&mut self.get_attestation_participants(
&a.data,
&a.aggregation_bitfield,
spec,
)?);
Ok(acc)
})?;
all_participants.sort_unstable();
all_participants.dedup();
Ok(all_participants)
}
// TODO: analyse for efficiency improvments. This implementation is naive.