diff --git a/consensus-types/light-client/bootstrap.go b/consensus-types/light-client/bootstrap.go index 2aa058cd57..7201b716b8 100644 --- a/consensus-types/light-client/bootstrap.go +++ b/consensus-types/light-client/bootstrap.go @@ -29,6 +29,9 @@ func NewWrappedBootstrap(m proto.Message) (interfaces.LightClientBootstrap, erro } } +// In addition to the proto object being wrapped, we store some fields that have to be +// constructed from the proto, so that we don't have to reconstruct them every time +// in getters. type bootstrapAltair struct { p *pb.LightClientBootstrapAltair header interfaces.LightClientHeader @@ -88,7 +91,7 @@ func (h *bootstrapAltair) Header() interfaces.LightClientHeader { } func (h *bootstrapAltair) SetHeader(header interfaces.LightClientHeader) error { - p, ok := (header.Proto()).(*pb.LightClientHeaderAltair) + p, ok := header.Proto().(*pb.LightClientHeaderAltair) if !ok { return fmt.Errorf("header type %T is not %T", header.Proto(), &pb.LightClientHeaderAltair{}) } @@ -127,6 +130,9 @@ func (h *bootstrapAltair) CurrentSyncCommitteeBranchElectra() (interfaces.LightC return [6][32]byte{}, consensustypes.ErrNotSupported("CurrentSyncCommitteeBranchElectra", version.Altair) } +// In addition to the proto object being wrapped, we store some fields that have to be +// constructed from the proto, so that we don't have to reconstruct them every time +// in getters. type bootstrapCapella struct { p *pb.LightClientBootstrapCapella header interfaces.LightClientHeader @@ -186,7 +192,7 @@ func (h *bootstrapCapella) Header() interfaces.LightClientHeader { } func (h *bootstrapCapella) SetHeader(header interfaces.LightClientHeader) error { - p, ok := (header.Proto()).(*pb.LightClientHeaderCapella) + p, ok := header.Proto().(*pb.LightClientHeaderCapella) if !ok { return fmt.Errorf("header type %T is not %T", header.Proto(), &pb.LightClientHeaderCapella{}) } @@ -225,6 +231,9 @@ func (h *bootstrapCapella) CurrentSyncCommitteeBranchElectra() (interfaces.Light return [6][32]byte{}, consensustypes.ErrNotSupported("CurrentSyncCommitteeBranchElectra", version.Capella) } +// In addition to the proto object being wrapped, we store some fields that have to be +// constructed from the proto, so that we don't have to reconstruct them every time +// in getters. type bootstrapDeneb struct { p *pb.LightClientBootstrapDeneb header interfaces.LightClientHeader @@ -284,7 +293,7 @@ func (h *bootstrapDeneb) Header() interfaces.LightClientHeader { } func (h *bootstrapDeneb) SetHeader(header interfaces.LightClientHeader) error { - p, ok := (header.Proto()).(*pb.LightClientHeaderDeneb) + p, ok := header.Proto().(*pb.LightClientHeaderDeneb) if !ok { return fmt.Errorf("header type %T is not %T", header.Proto(), &pb.LightClientHeaderDeneb{}) } @@ -323,6 +332,9 @@ func (h *bootstrapDeneb) CurrentSyncCommitteeBranchElectra() (interfaces.LightCl return [6][32]byte{}, consensustypes.ErrNotSupported("CurrentSyncCommitteeBranchElectra", version.Deneb) } +// In addition to the proto object being wrapped, we store some fields that have to be +// constructed from the proto, so that we don't have to reconstruct them every time +// in getters. type bootstrapElectra struct { p *pb.LightClientBootstrapElectra header interfaces.LightClientHeader @@ -382,7 +394,7 @@ func (h *bootstrapElectra) Header() interfaces.LightClientHeader { } func (h *bootstrapElectra) SetHeader(header interfaces.LightClientHeader) error { - p, ok := (header.Proto()).(*pb.LightClientHeaderDeneb) + p, ok := header.Proto().(*pb.LightClientHeaderDeneb) if !ok { return fmt.Errorf("header type %T is not %T", header.Proto(), &pb.LightClientHeaderDeneb{}) } diff --git a/consensus-types/light-client/finality_update.go b/consensus-types/light-client/finality_update.go index 465ba2b353..d728130ccd 100644 --- a/consensus-types/light-client/finality_update.go +++ b/consensus-types/light-client/finality_update.go @@ -89,6 +89,9 @@ func NewFinalityUpdateFromUpdate(update interfaces.LightClientUpdate) (interface } } +// In addition to the proto object being wrapped, we store some fields that have to be +// constructed from the proto, so that we don't have to reconstruct them every time +// in getters. type finalityUpdateAltair struct { p *pb.LightClientFinalityUpdateAltair attestedHeader interfaces.LightClientHeader @@ -188,6 +191,9 @@ func (u *finalityUpdateAltair) SignatureSlot() primitives.Slot { return u.p.SignatureSlot } +// In addition to the proto object being wrapped, we store some fields that have to be +// constructed from the proto, so that we don't have to reconstruct them every time +// in getters. type finalityUpdateCapella struct { p *pb.LightClientFinalityUpdateCapella attestedHeader interfaces.LightClientHeader @@ -287,6 +293,9 @@ func (u *finalityUpdateCapella) SignatureSlot() primitives.Slot { return u.p.SignatureSlot } +// In addition to the proto object being wrapped, we store some fields that have to be +// constructed from the proto, so that we don't have to reconstruct them every time +// in getters. type finalityUpdateDeneb struct { p *pb.LightClientFinalityUpdateDeneb attestedHeader interfaces.LightClientHeader @@ -386,6 +395,9 @@ func (u *finalityUpdateDeneb) SignatureSlot() primitives.Slot { return u.p.SignatureSlot } +// In addition to the proto object being wrapped, we store some fields that have to be +// constructed from the proto, so that we don't have to reconstruct them every time +// in getters. type finalityUpdateElectra struct { p *pb.LightClientFinalityUpdateElectra attestedHeader interfaces.LightClientHeader diff --git a/consensus-types/light-client/optimistic_update.go b/consensus-types/light-client/optimistic_update.go index 6e88774b62..15fa12eb62 100644 --- a/consensus-types/light-client/optimistic_update.go +++ b/consensus-types/light-client/optimistic_update.go @@ -70,6 +70,9 @@ func NewOptimisticUpdateFromUpdate(update interfaces.LightClientUpdate) (interfa } } +// In addition to the proto object being wrapped, we store some fields that have to be +// constructed from the proto, so that we don't have to reconstruct them every time +// in getters. type optimisticUpdateAltair struct { p *pb.LightClientOptimisticUpdateAltair attestedHeader interfaces.LightClientHeader @@ -141,6 +144,9 @@ func (u *optimisticUpdateAltair) SignatureSlot() primitives.Slot { return u.p.SignatureSlot } +// In addition to the proto object being wrapped, we store some fields that have to be +// constructed from the proto, so that we don't have to reconstruct them every time +// in getters. type optimisticUpdateCapella struct { p *pb.LightClientOptimisticUpdateCapella attestedHeader interfaces.LightClientHeader @@ -212,6 +218,9 @@ func (u *optimisticUpdateCapella) SignatureSlot() primitives.Slot { return u.p.SignatureSlot } +// In addition to the proto object being wrapped, we store some fields that have to be +// constructed from the proto, so that we don't have to reconstruct them every time +// in getters. type optimisticUpdateDeneb struct { p *pb.LightClientOptimisticUpdateDeneb attestedHeader interfaces.LightClientHeader diff --git a/consensus-types/light-client/update.go b/consensus-types/light-client/update.go index 3eccf1af3c..dfa6f1742c 100644 --- a/consensus-types/light-client/update.go +++ b/consensus-types/light-client/update.go @@ -113,11 +113,11 @@ func (u *updateAltair) AttestedHeader() interfaces.LightClientHeader { } func (u *updateAltair) SetAttestedHeader(header interfaces.LightClientHeader) error { - proto, ok := header.Proto().(*pb.LightClientHeaderAltair) + p, ok := header.Proto().(*pb.LightClientHeaderAltair) if !ok { return fmt.Errorf("header type %T is not %T", header.Proto(), &pb.LightClientHeaderAltair{}) } - u.p.AttestedHeader = proto + u.p.AttestedHeader = p u.attestedHeader = header return nil } @@ -155,11 +155,11 @@ func (u *updateAltair) FinalizedHeader() interfaces.LightClientHeader { } func (u *updateAltair) SetFinalizedHeader(header interfaces.LightClientHeader) error { - proto, ok := header.Proto().(*pb.LightClientHeaderAltair) + p, ok := header.Proto().(*pb.LightClientHeaderAltair) if !ok { return fmt.Errorf("header type %T is not %T", header.Proto(), &pb.LightClientHeaderAltair{}) } - u.p.FinalizedHeader = proto + u.p.FinalizedHeader = p u.finalizedHeader = header return nil } @@ -280,11 +280,11 @@ func (u *updateCapella) AttestedHeader() interfaces.LightClientHeader { } func (u *updateCapella) SetAttestedHeader(header interfaces.LightClientHeader) error { - proto, ok := header.Proto().(*pb.LightClientHeaderCapella) + p, ok := header.Proto().(*pb.LightClientHeaderCapella) if !ok { return fmt.Errorf("header type %T is not %T", header.Proto(), &pb.LightClientHeaderCapella{}) } - u.p.AttestedHeader = proto + u.p.AttestedHeader = p u.attestedHeader = header return nil } @@ -322,11 +322,11 @@ func (u *updateCapella) FinalizedHeader() interfaces.LightClientHeader { } func (u *updateCapella) SetFinalizedHeader(header interfaces.LightClientHeader) error { - proto, ok := header.Proto().(*pb.LightClientHeaderCapella) + p, ok := header.Proto().(*pb.LightClientHeaderCapella) if !ok { return fmt.Errorf("header type %T is not %T", header.Proto(), &pb.LightClientHeaderCapella{}) } - u.p.FinalizedHeader = proto + u.p.FinalizedHeader = p u.finalizedHeader = header return nil } @@ -447,11 +447,11 @@ func (u *updateDeneb) AttestedHeader() interfaces.LightClientHeader { } func (u *updateDeneb) SetAttestedHeader(header interfaces.LightClientHeader) error { - proto, ok := header.Proto().(*pb.LightClientHeaderDeneb) + p, ok := header.Proto().(*pb.LightClientHeaderDeneb) if !ok { return fmt.Errorf("header type %T is not %T", header.Proto(), &pb.LightClientHeaderDeneb{}) } - u.p.AttestedHeader = proto + u.p.AttestedHeader = p u.attestedHeader = header return nil } @@ -489,11 +489,11 @@ func (u *updateDeneb) FinalizedHeader() interfaces.LightClientHeader { } func (u *updateDeneb) SetFinalizedHeader(header interfaces.LightClientHeader) error { - proto, ok := header.Proto().(*pb.LightClientHeaderDeneb) + p, ok := header.Proto().(*pb.LightClientHeaderDeneb) if !ok { return fmt.Errorf("header type %T is not %T", header.Proto(), &pb.LightClientHeaderDeneb{}) } - u.p.FinalizedHeader = proto + u.p.FinalizedHeader = p u.finalizedHeader = header return nil } @@ -615,11 +615,11 @@ func (u *updateElectra) AttestedHeader() interfaces.LightClientHeader { } func (u *updateElectra) SetAttestedHeader(header interfaces.LightClientHeader) error { - proto, ok := header.Proto().(*pb.LightClientHeaderDeneb) + p, ok := header.Proto().(*pb.LightClientHeaderDeneb) if !ok { return fmt.Errorf("header type %T is not %T", header.Proto(), &pb.LightClientHeaderDeneb{}) } - u.p.AttestedHeader = proto + u.p.AttestedHeader = p u.attestedHeader = header return nil } @@ -657,11 +657,11 @@ func (u *updateElectra) FinalizedHeader() interfaces.LightClientHeader { } func (u *updateElectra) SetFinalizedHeader(header interfaces.LightClientHeader) error { - proto, ok := header.Proto().(*pb.LightClientHeaderDeneb) + p, ok := header.Proto().(*pb.LightClientHeaderDeneb) if !ok { return fmt.Errorf("header type %T is not %T", header.Proto(), &pb.LightClientHeaderDeneb{}) } - u.p.FinalizedHeader = proto + u.p.FinalizedHeader = p u.finalizedHeader = header return nil }