api

package
v1.14.6-0...-341647f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2024 License: GPL-3.0 Imports: 20 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("404 Not Found")
	ErrInternal = errors.New("500 Internal Server Error")
)

Functions

This section is empty.

Types

type ApiServer

type ApiServer struct {
	// contains filtered or unexported fields
}

ApiServer is a wrapper around BeaconLightApi that implements request.requestServer.

func NewApiServer

func NewApiServer(api *BeaconLightApi) *ApiServer

NewApiServer creates a new ApiServer.

func (*ApiServer) Name

func (s *ApiServer) Name() string

Name implements request.Server

func (*ApiServer) SendRequest

func (s *ApiServer) SendRequest(id request.ID, req request.Request)

SendRequest implements request.requestServer.

func (*ApiServer) Subscribe

func (s *ApiServer) Subscribe(eventCallback func(event request.Event))

Subscribe implements request.requestServer.

func (*ApiServer) Unsubscribe

func (s *ApiServer) Unsubscribe()

Unsubscribe implements request.requestServer. Note: Unsubscribe should not be called concurrently with Subscribe.

type BeaconLightApi

type BeaconLightApi struct {
	// contains filtered or unexported fields
}

BeaconLightApi requests light client information from a beacon node REST API. Note: all required API endpoints are currently only implemented by Lodestar.

func NewBeaconLightApi

func NewBeaconLightApi(url string, customHeaders map[string]string) *BeaconLightApi

func (*BeaconLightApi) GetBeaconBlock

func (api *BeaconLightApi) GetBeaconBlock(blockRoot common.Hash) (*types.BeaconBlock, error)

func (*BeaconLightApi) GetBestUpdatesAndCommittees

func (api *BeaconLightApi) GetBestUpdatesAndCommittees(firstPeriod, count uint64) ([]*types.LightClientUpdate, []*types.SerializedSyncCommittee, error)

GetBestUpdatesAndCommittees fetches and validates LightClientUpdate for given period and full serialized committee for the next period (committee root hash equals update.NextSyncCommitteeRoot). Note that the results are validated but the update signature should be verified by the caller as its validity depends on the update chain.

func (*BeaconLightApi) GetCheckpointData

func (api *BeaconLightApi) GetCheckpointData(checkpointHash common.Hash) (*types.BootstrapData, error)

GetCheckpointData fetches and validates bootstrap data belonging to the given checkpoint.

func (*BeaconLightApi) GetFinalityUpdate

func (api *BeaconLightApi) GetFinalityUpdate() (types.FinalityUpdate, error)

GetFinalityUpdate fetches the latest available finality update.

See data structure definition here: https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate

func (*BeaconLightApi) GetHeader

func (api *BeaconLightApi) GetHeader(blockRoot common.Hash) (types.Header, bool, bool, error)

GetHeader fetches and validates the beacon header with the given blockRoot. If blockRoot is null hash then the latest head header is fetched. The values of the canonical and finalized flags are also returned. Note that these flags are not validated.

func (*BeaconLightApi) GetOptimisticUpdate

func (api *BeaconLightApi) GetOptimisticUpdate() (types.OptimisticUpdate, error)

GetOptimisticUpdate fetches the latest available optimistic update. Note that the signature should be verified by the caller as its validity depends on the update chain.

See data structure definition here: https://github.com/ethereum/consensus-specs/blob/dev/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate

func (*BeaconLightApi) StartHeadListener

func (api *BeaconLightApi) StartHeadListener(listener HeadEventListener) func()

StartHeadListener creates an event subscription for heads and signed (optimistic) head updates and calls the specified callback functions when they are received. The callbacks are also called for the current head and optimistic head at startup. They are never called concurrently.

type CommitteeUpdate

type CommitteeUpdate struct {
	Version           string
	Update            types.LightClientUpdate
	NextSyncCommittee types.SerializedSyncCommittee
}

func (*CommitteeUpdate) UnmarshalJSON

func (u *CommitteeUpdate) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type HeadEventListener

type HeadEventListener struct {
	OnNewHead    func(slot uint64, blockRoot common.Hash)
	OnOptimistic func(head types.OptimisticUpdate)
	OnFinality   func(head types.FinalityUpdate)
	OnError      func(err error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL