Skip to content

Commit

Permalink
separate nil error checks
Browse files Browse the repository at this point in the history
  • Loading branch information
potuz committed May 16, 2023
1 parent a64a6f9 commit 3dea7dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion beacon-chain/operations/attestations/kv/aggregated.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ func (c *AttCaches) aggregateUnaggregatedAttestations(ctx context.Context, unagg
leftOverUnaggregatedAtt := make(map[[32]byte]bool)
for _, atts := range attsByDataRoot {
aggregated, err := attaggregation.AggregateDisjointOneBitAtts(atts)
if err != nil || aggregated == nil {
if err != nil {
return errors.Wrap(err, "could not aggregate unaggregated attestations")
}
if aggregated == nil {
return errors.New("could not aggregate unaggregated attestations")
}
if helpers.IsAggregated(aggregated) {
if err := c.SaveAggregatedAttestations([]*ethpb.Attestation{aggregated}); err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ func AggregateDisjointOneBitAtts(atts []*ethpb.Attestation) (*ethpb.Attestation,
keys[i] = i
}
idx, err := aggregateAttestations(atts, keys, coverage)
if err != nil || idx != 0 {
if err != nil {
return nil, errors.Wrap(err, "could not aggregate attestations")
}
if idx != 0 {
return nil, errors.New("could not aggregate attestations, obtained non zero index")
}
return atts[0], nil
}

Expand Down

0 comments on commit 3dea7dc

Please sign in to comment.