Skip to content

Commit 7d67d0d

Browse files
committed
Use superstruct mapping macros
1 parent b0a3a14 commit 7d67d0d

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

consensus/types/src/light_client_update.rs

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -417,30 +417,18 @@ impl<E: EthSpec> LightClientUpdate<E> {
417417
return Ok(new.signature_slot() < self.signature_slot());
418418
}
419419

420-
fn is_next_sync_committee_branch_empty(&self) -> bool {
421-
match self {
422-
LightClientUpdate::Electra(update) => {
423-
is_empty_branch(update.next_sync_committee_branch.as_ref())
424-
}
425-
LightClientUpdate::Deneb(update) => {
426-
is_empty_branch(update.next_sync_committee_branch.as_ref())
427-
}
428-
LightClientUpdate::Capella(update) => {
429-
is_empty_branch(update.next_sync_committee_branch.as_ref())
430-
}
431-
LightClientUpdate::Altair(update) => {
432-
is_empty_branch(update.next_sync_committee_branch.as_ref())
433-
}
434-
}
420+
fn is_next_sync_committee_branch_empty<'a>(&'a self) -> bool {
421+
map_light_client_update_ref!(&'a _, self.to_ref(), |update, cons| {
422+
cons(update);
423+
is_empty_branch(update.next_sync_committee_branch.as_ref())
424+
})
435425
}
436426

437-
pub fn is_finality_branch_empty(&self) -> bool {
438-
match self {
439-
LightClientUpdate::Electra(update) => is_empty_branch(update.finality_branch.as_ref()),
440-
LightClientUpdate::Deneb(update) => is_empty_branch(update.finality_branch.as_ref()),
441-
LightClientUpdate::Capella(update) => is_empty_branch(update.finality_branch.as_ref()),
442-
LightClientUpdate::Altair(update) => is_empty_branch(update.finality_branch.as_ref()),
443-
}
427+
pub fn is_finality_branch_empty<'a>(&'a self) -> bool {
428+
map_light_client_update_ref!(&'a _, self.to_ref(), |update, cons| {
429+
cons(update);
430+
is_empty_branch(update.finality_branch.as_ref())
431+
})
444432
}
445433
}
446434

0 commit comments

Comments
 (0)