Skip to content

Commit b8c6e49

Browse files
michaelsprouljtraglia
authored andcommitted
Simplify length methods on BeaconBlockBody (sigp#7989)
Just the low-hanging fruit from: - sigp#7988
1 parent 84519c6 commit b8c6e49

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

consensus/types/src/beacon_block_body.rs

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -318,29 +318,17 @@ impl<'a, E: EthSpec, Payload: AbstractExecPayload<E>> BeaconBlockBodyRef<'a, E,
318318
}
319319

320320
pub fn attestations_len(&self) -> usize {
321-
match self {
322-
Self::Base(body) => body.attestations.len(),
323-
Self::Altair(body) => body.attestations.len(),
324-
Self::Bellatrix(body) => body.attestations.len(),
325-
Self::Capella(body) => body.attestations.len(),
326-
Self::Deneb(body) => body.attestations.len(),
327-
Self::Electra(body) => body.attestations.len(),
328-
Self::Fulu(body) => body.attestations.len(),
329-
Self::Gloas(body) => body.attestations.len(),
330-
}
321+
map_beacon_block_body_ref!(&'a _, self, |inner, cons| {
322+
cons(inner);
323+
inner.attestations.len()
324+
})
331325
}
332326

333327
pub fn attester_slashings_len(&self) -> usize {
334-
match self {
335-
Self::Base(body) => body.attester_slashings.len(),
336-
Self::Altair(body) => body.attester_slashings.len(),
337-
Self::Bellatrix(body) => body.attester_slashings.len(),
338-
Self::Capella(body) => body.attester_slashings.len(),
339-
Self::Deneb(body) => body.attester_slashings.len(),
340-
Self::Electra(body) => body.attester_slashings.len(),
341-
Self::Fulu(body) => body.attester_slashings.len(),
342-
Self::Gloas(body) => body.attester_slashings.len(),
343-
}
328+
map_beacon_block_body_ref!(&'a _, self, |inner, cons| {
329+
cons(inner);
330+
inner.attester_slashings.len()
331+
})
344332
}
345333

346334
pub fn attestations(&self) -> Box<dyn Iterator<Item = AttestationRef<'a, E>> + 'a> {

0 commit comments

Comments
 (0)