mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 09:16:00 +00:00
Use ok_or instead of if let else
This commit is contained in:
@@ -122,32 +122,32 @@ pub mod attesting_indices_electra {
|
|||||||
let committee_count_per_slot = committees.len() as u64;
|
let committee_count_per_slot = committees.len() as u64;
|
||||||
let mut participant_count = 0;
|
let mut participant_count = 0;
|
||||||
for index in committee_indices {
|
for index in committee_indices {
|
||||||
if let Some(&beacon_committee) = committees_map.get(&index) {
|
let beacon_committee = committees_map
|
||||||
// This check is new to the spec's `process_attestation` in Electra.
|
.get(&index)
|
||||||
if index >= committee_count_per_slot {
|
.ok_or(Error::NoCommitteeFound(index))?;
|
||||||
return Err(BeaconStateError::InvalidCommitteeIndex(index));
|
|
||||||
}
|
|
||||||
participant_count.safe_add_assign(beacon_committee.committee.len() as u64)?;
|
|
||||||
let committee_attesters = beacon_committee
|
|
||||||
.committee
|
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.filter_map(|(i, &index)| {
|
|
||||||
if let Ok(aggregation_bit_index) = committee_offset.safe_add(i) {
|
|
||||||
if aggregation_bits.get(aggregation_bit_index).unwrap_or(false) {
|
|
||||||
return Some(index as u64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
})
|
|
||||||
.collect::<HashSet<u64>>();
|
|
||||||
|
|
||||||
output.extend(committee_attesters);
|
// This check is new to the spec's `process_attestation` in Electra.
|
||||||
|
if index >= committee_count_per_slot {
|
||||||
committee_offset.safe_add_assign(beacon_committee.committee.len())?;
|
return Err(BeaconStateError::InvalidCommitteeIndex(index));
|
||||||
} else {
|
|
||||||
return Err(Error::NoCommitteeFound(index));
|
|
||||||
}
|
}
|
||||||
|
participant_count.safe_add_assign(beacon_committee.committee.len() as u64)?;
|
||||||
|
let committee_attesters = beacon_committee
|
||||||
|
.committee
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.filter_map(|(i, &index)| {
|
||||||
|
if let Ok(aggregation_bit_index) = committee_offset.safe_add(i) {
|
||||||
|
if aggregation_bits.get(aggregation_bit_index).unwrap_or(false) {
|
||||||
|
return Some(index as u64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
})
|
||||||
|
.collect::<HashSet<u64>>();
|
||||||
|
|
||||||
|
output.extend(committee_attesters);
|
||||||
|
|
||||||
|
committee_offset.safe_add_assign(beacon_committee.committee.len())?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This check is new to the spec's `process_attestation` in Electra.
|
// This check is new to the spec's `process_attestation` in Electra.
|
||||||
|
|||||||
Reference in New Issue
Block a user