Skip to content

Commit

Permalink
feat: Add FetchBeaconBlockHeader method
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Sep 19, 2024
1 parent d196706 commit 2fc9d92
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 @@ -97,6 +97,8 @@ type Node interface {
FetchAttestationData(ctx context.Context, slot phase0.Slot, committeeIndex phase0.CommitteeIndex) (*phase0.AttestationData, error)
// FetchBeaconBlockBlobs fetches blob sidecars for the given block id.
FetchBeaconBlockBlobs(ctx context.Context, blockID string) ([]*deneb.BlobSidecar, error)
// FetchBeaconBlockHeader fetches beacon block headers.
FetchBeaconBlockHeader(ctx context.Context, opts *eapi.BeaconBlockHeaderOpts) (*v1.BeaconBlockHeader, error)

// Subscriptions
// - Proxied Beacon events
Expand Down
14 changes: 14 additions & 0 deletions pkg/beacon/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,17 @@ func (n *node) FetchAttestationData(ctx context.Context, slot phase0.Slot, commi

return rsp.Data, nil
}

func (n *node) FetchBeaconBlockHeader(ctx context.Context, opts *api.BeaconBlockHeaderOpts) (*v1.BeaconBlockHeader, error) {
provider, isProvider := n.client.(eth2client.BeaconBlockHeadersProvider)
if !isProvider {
return nil, errors.New("client does not implement eth2client.BeaconBlockHeadersProvider")
}

rsp, err := provider.BeaconBlockHeader(ctx, opts)
if err != nil {
return nil, err
}

return rsp.Data, nil
}

0 comments on commit 2fc9d92

Please sign in to comment.