Ensure attestation_participants is deduped
This commit is contained in:
parent
d6adfc7655
commit
e1239a1ecc
@ -18,14 +18,19 @@ impl BeaconState {
|
|||||||
attestations: &[&PendingAttestation],
|
attestations: &[&PendingAttestation],
|
||||||
spec: &ChainSpec,
|
spec: &ChainSpec,
|
||||||
) -> Result<Vec<usize>, Error> {
|
) -> Result<Vec<usize>, Error> {
|
||||||
attestations.iter().try_fold(vec![], |mut acc, a| {
|
let mut all_participants = attestations
|
||||||
|
.iter()
|
||||||
|
.try_fold::<_, _, Result<Vec<usize>, Error>>(vec![], |mut acc, a| {
|
||||||
acc.append(&mut self.get_attestation_participants(
|
acc.append(&mut self.get_attestation_participants(
|
||||||
&a.data,
|
&a.data,
|
||||||
&a.aggregation_bitfield,
|
&a.aggregation_bitfield,
|
||||||
spec,
|
spec,
|
||||||
)?);
|
)?);
|
||||||
Ok(acc)
|
Ok(acc)
|
||||||
})
|
})?;
|
||||||
|
all_participants.sort_unstable();
|
||||||
|
all_participants.dedup();
|
||||||
|
Ok(all_participants)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: analyse for efficiency improvments. This implementation is naive.
|
// TODO: analyse for efficiency improvments. This implementation is naive.
|
||||||
|
Loading…
Reference in New Issue
Block a user