Skip to content

Commit

Permalink
Fix linting.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed Jul 20, 2023
1 parent 6dbe2ec commit 9402fb5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
4 changes: 2 additions & 2 deletions api/v1/forkchoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ var ForkChoiceNodeValidityStrings = [...]string{
}

func ForkChoiceNodeValidityFromString(input string) (ForkChoiceNodeValidity, error) {
switch strings.ToLower(string(input)) {
switch strings.ToLower(input) {
case "invalid":
return ForkChoiceNodeValidityInvalid, nil
case "valid":
return ForkChoiceNodeValidityValid, nil
case "optimistic":
return ForkChoiceNodeValidityOptimistic, nil
default:
return ForkChoiceNodeValidityUnknown, fmt.Errorf("unrecognised fork choice validity: %s", string(input))
return ForkChoiceNodeValidityUnknown, fmt.Errorf("unrecognised fork choice validity: %s", input)
}
}

Expand Down
2 changes: 1 addition & 1 deletion api/v1/forkchoice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"

api "github.com/attestantio/go-eth2-client/api/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gotest.tools/assert"
)

func TestForkChoiceJSON(t *testing.T) {
Expand Down
30 changes: 30 additions & 0 deletions spec/versionedsignedbeaconblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,36 @@ func (v *VersionedSignedBeaconBlock) ProposerSlashings() ([]*phase0.ProposerSlas
}
}

// SyncAggregate returns the sync aggregate of the beacon block.
func (v *VersionedSignedBeaconBlock) SyncAggregate() (*altair.SyncAggregate, error) {
switch v.Version {
case DataVersionPhase0:
return nil, errors.New("phase0 block does not have sync aggregate")
case DataVersionAltair:
if v.Altair == nil {
return nil, errors.New("no altair block")
}
return v.Altair.Message.Body.SyncAggregate, nil
case DataVersionBellatrix:
if v.Bellatrix == nil {
return nil, errors.New("no bellatrix block")
}
return v.Bellatrix.Message.Body.SyncAggregate, nil
case DataVersionCapella:
if v.Capella == nil {
return nil, errors.New("no capella block")
}
return v.Capella.Message.Body.SyncAggregate, nil
case DataVersionDeneb:
if v.Deneb == nil {
return nil, errors.New("no deneb block")
}
return v.Deneb.Message.Body.SyncAggregate, nil
default:
return nil, errors.New("unknown version")
}
}

// String returns a string version of the structure.
func (v *VersionedSignedBeaconBlock) String() string {
switch v.Version {
Expand Down

0 comments on commit 9402fb5

Please sign in to comment.