Documentation ¶
Overview ¶
Package beaconclient provides a beacon-node client
Index ¶
- Variables
- type AllValidatorsResponse
- type GetBlockResponse
- type GetHeaderResponse
- type GetHeaderResponseMessage
- type HeadEventData
- type IBeaconInstance
- type IMultiBeaconClient
- type MockBeaconInstance
- func (c *MockBeaconInstance) AddValidator(entry ValidatorResponseEntry)
- func (c *MockBeaconInstance) CurrentSlot() (uint64, error)
- func (c *MockBeaconInstance) FetchValidators(headSlot uint64) (map[types.PubkeyHex]ValidatorResponseEntry, error)
- func (c *MockBeaconInstance) GetProposerDuties(epoch uint64) (*ProposerDutiesResponse, error)
- func (c *MockBeaconInstance) GetURI() string
- func (c *MockBeaconInstance) IsValidator(pubkey types.PubkeyHex) bool
- func (c *MockBeaconInstance) NumValidators() uint64
- func (c *MockBeaconInstance) PublishBlock(block *types.SignedBeaconBlock) (code int, err error)
- func (c *MockBeaconInstance) SetValidators(validatorSet map[types.PubkeyHex]ValidatorResponseEntry)
- func (c *MockBeaconInstance) SubscribeToHeadEvents(slotC chan HeadEventData)
- func (c *MockBeaconInstance) SyncStatus() (*SyncStatusPayloadData, error)
- type MultiBeaconClient
- func (c *MultiBeaconClient) BestSyncStatus() (*SyncStatusPayloadData, error)
- func (c *MultiBeaconClient) FetchValidators(headSlot uint64) (map[types.PubkeyHex]ValidatorResponseEntry, error)
- func (c *MultiBeaconClient) GetProposerDuties(epoch uint64) (*ProposerDutiesResponse, error)
- func (c *MultiBeaconClient) PublishBlock(block *types.SignedBeaconBlock) (code int, err error)
- func (c *MultiBeaconClient) SubscribeToHeadEvents(slotC chan HeadEventData)
- type ProdBeaconInstance
- func (c *ProdBeaconInstance) CurrentSlot() (uint64, error)
- func (c *ProdBeaconInstance) FetchValidators(headSlot uint64) (map[types.PubkeyHex]ValidatorResponseEntry, error)
- func (c *ProdBeaconInstance) GetBlock() (*GetBlockResponse, error)
- func (c *ProdBeaconInstance) GetHeader() (*GetHeaderResponse, error)
- func (c *ProdBeaconInstance) GetProposerDuties(epoch uint64) (*ProposerDutiesResponse, error)
- func (c *ProdBeaconInstance) GetURI() string
- func (c *ProdBeaconInstance) PublishBlock(block *types.SignedBeaconBlock) (code int, err error)
- func (c *ProdBeaconInstance) SubscribeToHeadEvents(slotC chan HeadEventData)
- func (c *ProdBeaconInstance) SyncStatus() (*SyncStatusPayloadData, error)
- type ProposerDutiesResponse
- type ProposerDutiesResponseData
- type SyncStatusPayload
- type SyncStatusPayloadData
- type ValidatorResponseEntry
- type ValidatorResponseValidatorData
Constants ¶
This section is empty.
Variables ¶
var ( ErrBeaconNodeSyncing = errors.New("beacon node is syncing or unavailable") )
var ErrHTTPErrorResponse = errors.New("got an HTTP error response")
Functions ¶
This section is empty.
Types ¶
type AllValidatorsResponse ¶
type AllValidatorsResponse struct {
Data []ValidatorResponseEntry
}
type GetBlockResponse ¶
type GetBlockResponse struct { Data struct { Message struct { Slot uint64 `json:"slot,string"` Body struct { ExecutionPayload types.ExecutionPayload `json:"execution_payload"` } } } }
type GetHeaderResponse ¶
type GetHeaderResponse struct { Data struct { Root string `json:"root"` Header struct { Message *GetHeaderResponseMessage } } }
type HeadEventData ¶
type HeadEventData struct { Slot uint64 `json:"slot,string"` Block string `json:"block"` State string `json:"state"` }
HeadEventData represents the data of a head event {"slot":"827256","block":"0x56b683afa68170c775f3c9debc18a6a72caea9055584d037333a6fe43c8ceb83","state":"0x419e2965320d69c4213782dae73941de802a4f436408fddd6f68b671b3ff4e55","epoch_transition":false,"execution_optimistic":false,"previous_duty_dependent_root":"0x5b81a526839b7fb67c3896f1125451755088fb578ad27c2690b3209f3d7c6b54","current_duty_dependent_root":"0x5f3232c0d5741e27e13754e1d88285c603b07dd6164b35ca57e94344a9e42942"}
type IBeaconInstance ¶ added in v0.5.1
type IBeaconInstance interface { SyncStatus() (*SyncStatusPayloadData, error) CurrentSlot() (uint64, error) SubscribeToHeadEvents(slotC chan HeadEventData) FetchValidators(headSlot uint64) (map[types.PubkeyHex]ValidatorResponseEntry, error) GetProposerDuties(epoch uint64) (*ProposerDutiesResponse, error) GetURI() string PublishBlock(block *types.SignedBeaconBlock) (code int, err error) }
IBeaconInstance is the interface for a single beacon client instance
type IMultiBeaconClient ¶ added in v0.5.1
type IMultiBeaconClient interface { BestSyncStatus() (*SyncStatusPayloadData, error) SubscribeToHeadEvents(slotC chan HeadEventData) FetchValidators(headSlot uint64) (map[types.PubkeyHex]ValidatorResponseEntry, error) GetProposerDuties(epoch uint64) (*ProposerDutiesResponse, error) PublishBlock(block *types.SignedBeaconBlock) (code int, err error) }
IMultiBeaconClient is the interface for the MultiBeaconClient, which can manage several beacon client instances under the hood
type MockBeaconInstance ¶ added in v0.5.1
type MockBeaconInstance struct { MockSyncStatus *SyncStatusPayloadData MockSyncStatusErr error MockProposerDuties *ProposerDutiesResponse MockProposerDutiesErr error MockFetchValidatorsErr error ResponseDelay time.Duration // contains filtered or unexported fields }
func NewMockBeaconInstance ¶ added in v0.5.1
func NewMockBeaconInstance() *MockBeaconInstance
func (*MockBeaconInstance) AddValidator ¶ added in v0.5.1
func (c *MockBeaconInstance) AddValidator(entry ValidatorResponseEntry)
func (*MockBeaconInstance) CurrentSlot ¶ added in v0.5.1
func (c *MockBeaconInstance) CurrentSlot() (uint64, error)
func (*MockBeaconInstance) FetchValidators ¶ added in v0.5.1
func (c *MockBeaconInstance) FetchValidators(headSlot uint64) (map[types.PubkeyHex]ValidatorResponseEntry, error)
func (*MockBeaconInstance) GetProposerDuties ¶ added in v0.5.1
func (c *MockBeaconInstance) GetProposerDuties(epoch uint64) (*ProposerDutiesResponse, error)
func (*MockBeaconInstance) GetURI ¶ added in v0.5.1
func (c *MockBeaconInstance) GetURI() string
func (*MockBeaconInstance) IsValidator ¶ added in v0.5.1
func (c *MockBeaconInstance) IsValidator(pubkey types.PubkeyHex) bool
func (*MockBeaconInstance) NumValidators ¶ added in v0.5.1
func (c *MockBeaconInstance) NumValidators() uint64
func (*MockBeaconInstance) PublishBlock ¶ added in v0.6.0
func (c *MockBeaconInstance) PublishBlock(block *types.SignedBeaconBlock) (code int, err error)
func (*MockBeaconInstance) SetValidators ¶ added in v0.5.1
func (c *MockBeaconInstance) SetValidators(validatorSet map[types.PubkeyHex]ValidatorResponseEntry)
func (*MockBeaconInstance) SubscribeToHeadEvents ¶ added in v0.5.1
func (c *MockBeaconInstance) SubscribeToHeadEvents(slotC chan HeadEventData)
func (*MockBeaconInstance) SyncStatus ¶ added in v0.5.1
func (c *MockBeaconInstance) SyncStatus() (*SyncStatusPayloadData, error)
type MultiBeaconClient ¶ added in v0.5.1
type MultiBeaconClient struct {
// contains filtered or unexported fields
}
func NewMultiBeaconClient ¶ added in v0.5.1
func NewMultiBeaconClient(log *logrus.Entry, beaconInstances []IBeaconInstance) *MultiBeaconClient
func (*MultiBeaconClient) BestSyncStatus ¶ added in v0.5.1
func (c *MultiBeaconClient) BestSyncStatus() (*SyncStatusPayloadData, error)
func (*MultiBeaconClient) FetchValidators ¶ added in v0.5.1
func (c *MultiBeaconClient) FetchValidators(headSlot uint64) (map[types.PubkeyHex]ValidatorResponseEntry, error)
func (*MultiBeaconClient) GetProposerDuties ¶ added in v0.5.1
func (c *MultiBeaconClient) GetProposerDuties(epoch uint64) (*ProposerDutiesResponse, error)
func (*MultiBeaconClient) PublishBlock ¶ added in v0.6.0
func (c *MultiBeaconClient) PublishBlock(block *types.SignedBeaconBlock) (code int, err error)
PublishBlock publishes the signed beacon block via https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/publishBlock
func (*MultiBeaconClient) SubscribeToHeadEvents ¶ added in v0.5.1
func (c *MultiBeaconClient) SubscribeToHeadEvents(slotC chan HeadEventData)
SubscribeToHeadEvents subscribes to head events from all beacon nodes. A single head event will be received multiple times, likely once for every beacon nodes.
type ProdBeaconInstance ¶ added in v0.5.1
type ProdBeaconInstance struct {
// contains filtered or unexported fields
}
func NewProdBeaconInstance ¶ added in v0.5.1
func NewProdBeaconInstance(log *logrus.Entry, beaconURI string) *ProdBeaconInstance
func (*ProdBeaconInstance) CurrentSlot ¶ added in v0.5.1
func (c *ProdBeaconInstance) CurrentSlot() (uint64, error)
func (*ProdBeaconInstance) FetchValidators ¶ added in v0.5.1
func (c *ProdBeaconInstance) FetchValidators(headSlot uint64) (map[types.PubkeyHex]ValidatorResponseEntry, error)
func (*ProdBeaconInstance) GetBlock ¶ added in v0.5.1
func (c *ProdBeaconInstance) GetBlock() (*GetBlockResponse, error)
GetBlock returns the latest block - https://ethereum.github.io/beacon-APIs/#/Beacon/getBlockV2
func (*ProdBeaconInstance) GetHeader ¶ added in v0.5.1
func (c *ProdBeaconInstance) GetHeader() (*GetHeaderResponse, error)
GetHeader returns the latest header - https://ethereum.github.io/beacon-APIs/#/Beacon/getBlockHeader
func (*ProdBeaconInstance) GetProposerDuties ¶ added in v0.5.1
func (c *ProdBeaconInstance) GetProposerDuties(epoch uint64) (*ProposerDutiesResponse, error)
GetProposerDuties returns proposer duties for every slot in this epoch https://ethereum.github.io/beacon-APIs/#/Validator/getProposerDuties
func (*ProdBeaconInstance) GetURI ¶ added in v0.5.1
func (c *ProdBeaconInstance) GetURI() string
func (*ProdBeaconInstance) PublishBlock ¶ added in v0.6.0
func (c *ProdBeaconInstance) PublishBlock(block *types.SignedBeaconBlock) (code int, err error)
func (*ProdBeaconInstance) SubscribeToHeadEvents ¶ added in v0.5.1
func (c *ProdBeaconInstance) SubscribeToHeadEvents(slotC chan HeadEventData)
func (*ProdBeaconInstance) SyncStatus ¶ added in v0.5.1
func (c *ProdBeaconInstance) SyncStatus() (*SyncStatusPayloadData, error)
SyncStatus returns the current node sync-status https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/getSyncingStatus
type ProposerDutiesResponse ¶
type ProposerDutiesResponse struct {
Data []ProposerDutiesResponseData
}
type SyncStatusPayload ¶
type SyncStatusPayload struct {
Data SyncStatusPayloadData
}
SyncStatusPayload is the response payload for /eth/v1/node/syncing {"data":{"head_slot":"251114","sync_distance":"0","is_syncing":false,"is_optimistic":false}}
type SyncStatusPayloadData ¶
type ValidatorResponseEntry ¶
type ValidatorResponseEntry struct { Index uint64 `json:"index,string"` // Index of validator in validator registry. Balance string `json:"balance"` // Current validator balance in gwei. Status string `json:"status"` Validator ValidatorResponseValidatorData `json:"validator"` }
type ValidatorResponseValidatorData ¶
type ValidatorResponseValidatorData struct {
Pubkey string `json:"pubkey"`
}