Skip to content

Commit

Permalink
feat: Add FetchRawSpec method to fetch raw spec from beacon node
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed May 12, 2024
1 parent 624f4c9 commit 55bb102
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/beacon/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ type Node interface {
FetchSyncStatus(ctx context.Context) (*v1.SyncState, error)
// FetchNodeVersion fetches the node version from the beacon node.
FetchNodeVersion(ctx context.Context) (string, error)
// FetchRawSpec fetches the raw, unparsed spec from the beacon node.
FetchRawSpec(ctx context.Context) (map[string]any, error)
// FetchSpec fetches the spec from the beacon node.
FetchSpec(ctx context.Context) (*state.Spec, error)
// FetchProposerDuties fetches the proposer duties from the beacon node.
Expand Down
14 changes: 14 additions & 0 deletions pkg/beacon/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ func (n *node) FetchFinality(ctx context.Context, stateID string) (*v1.Finality,
return finality, nil
}

func (n *node) FetchRawSpec(ctx context.Context) (map[string]any, error) {
provider, isProvider := n.client.(eth2client.SpecProvider)
if !isProvider {
return nil, errors.New("client does not implement eth2client.SpecProvider")
}

rsp, err := provider.Spec(ctx, &api.SpecOpts{})
if err != nil {
return nil, err
}

return rsp.Data, nil
}

func (n *node) FetchSpec(ctx context.Context) (*state.Spec, error) {
provider, isProvider := n.client.(eth2client.SpecProvider)
if !isProvider {
Expand Down

0 comments on commit 55bb102

Please sign in to comment.