From 76adedff2788f0f0d55bff96d6b0ffe1e96e8b39 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Thu, 4 Sep 2025 10:08:29 +1000 Subject: [PATCH] Simplify length methods on BeaconBlockBody (#7989) Just the low-hanging fruit from: - https://github.com/sigp/lighthouse/pull/7988 --- consensus/types/src/beacon_block_body.rs | 28 +++++++----------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/consensus/types/src/beacon_block_body.rs b/consensus/types/src/beacon_block_body.rs index 7df9c3f3cb..e636fbb534 100644 --- a/consensus/types/src/beacon_block_body.rs +++ b/consensus/types/src/beacon_block_body.rs @@ -318,29 +318,17 @@ impl<'a, E: EthSpec, Payload: AbstractExecPayload> BeaconBlockBodyRef<'a, E, } pub fn attestations_len(&self) -> usize { - match self { - Self::Base(body) => body.attestations.len(), - Self::Altair(body) => body.attestations.len(), - Self::Bellatrix(body) => body.attestations.len(), - Self::Capella(body) => body.attestations.len(), - Self::Deneb(body) => body.attestations.len(), - Self::Electra(body) => body.attestations.len(), - Self::Fulu(body) => body.attestations.len(), - Self::Gloas(body) => body.attestations.len(), - } + map_beacon_block_body_ref!(&'a _, self, |inner, cons| { + cons(inner); + inner.attestations.len() + }) } pub fn attester_slashings_len(&self) -> usize { - match self { - Self::Base(body) => body.attester_slashings.len(), - Self::Altair(body) => body.attester_slashings.len(), - Self::Bellatrix(body) => body.attester_slashings.len(), - Self::Capella(body) => body.attester_slashings.len(), - Self::Deneb(body) => body.attester_slashings.len(), - Self::Electra(body) => body.attester_slashings.len(), - Self::Fulu(body) => body.attester_slashings.len(), - Self::Gloas(body) => body.attester_slashings.len(), - } + map_beacon_block_body_ref!(&'a _, self, |inner, cons| { + cons(inner); + inner.attester_slashings.len() + }) } pub fn attestations(&self) -> Box> + 'a> {