Use ok_or instead of if let else

This commit is contained in:
dapplion
2024-06-19 12:50:41 +02:00
parent 9e6e76fb89
commit a8d8989c05

View File

@@ -122,7 +122,10 @@ 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
.get(&index)
.ok_or(Error::NoCommitteeFound(index))?;
// This check is new to the spec's `process_attestation` in Electra. // This check is new to the spec's `process_attestation` in Electra.
if index >= committee_count_per_slot { if index >= committee_count_per_slot {
return Err(BeaconStateError::InvalidCommitteeIndex(index)); return Err(BeaconStateError::InvalidCommitteeIndex(index));
@@ -145,9 +148,6 @@ pub mod attesting_indices_electra {
output.extend(committee_attesters); output.extend(committee_attesters);
committee_offset.safe_add_assign(beacon_committee.committee.len())?; committee_offset.safe_add_assign(beacon_committee.committee.len())?;
} else {
return Err(Error::NoCommitteeFound(index));
}
} }
// This check is new to the spec's `process_attestation` in Electra. // This check is new to the spec's `process_attestation` in Electra.