Documentation ¶
Overview ¶
Package beaconclient provides a beacon-node client
Index ¶
- Variables
- type AllValidatorsResponse
- type BeaconNodeClient
- type GetBlockResponse
- type GetHeaderResponse
- type GetHeaderResponseMessage
- type HeadEventData
- type MockBeaconClient
- func (c *MockBeaconClient) AddValidator(entry ValidatorResponseEntry)
- func (c *MockBeaconClient) CurrentSlot() (uint64, error)
- func (c *MockBeaconClient) FetchValidators(headSlot uint64) (map[types.PubkeyHex]ValidatorResponseEntry, error)
- func (c *MockBeaconClient) GetProposerDuties(epoch uint64) (*ProposerDutiesResponse, error)
- func (c *MockBeaconClient) GetURI() string
- func (c *MockBeaconClient) IsValidator(pubkey types.PubkeyHex) bool
- func (c *MockBeaconClient) NumValidators() uint64
- func (c *MockBeaconClient) SetValidators(validatorSet map[types.PubkeyHex]ValidatorResponseEntry)
- func (c *MockBeaconClient) SubscribeToHeadEvents(slotC chan HeadEventData)
- func (c *MockBeaconClient) SyncStatus() (*SyncStatusPayloadData, error)
- type ProdBeaconClient
- func (c *ProdBeaconClient) CurrentSlot() (uint64, error)
- func (c *ProdBeaconClient) FetchValidators(headSlot uint64) (map[types.PubkeyHex]ValidatorResponseEntry, error)
- func (c *ProdBeaconClient) GetBlock() (*GetBlockResponse, error)
- func (c *ProdBeaconClient) GetHeader() (*GetHeaderResponse, error)
- func (c *ProdBeaconClient) GetProposerDuties(epoch uint64) (*ProposerDutiesResponse, error)
- func (c *ProdBeaconClient) GetURI() string
- func (c *ProdBeaconClient) SubscribeToHeadEvents(slotC chan HeadEventData)
- func (c *ProdBeaconClient) SyncStatus() (*SyncStatusPayloadData, error)
- type ProposerDutiesResponse
- type ProposerDutiesResponseData
- type SyncStatusPayload
- type SyncStatusPayloadData
- type ValidatorResponseEntry
- type ValidatorResponseValidatorData
Constants ¶
This section is empty.
Variables ¶
var ErrHTTPErrorResponse = errors.New("got an HTTP error response")
Functions ¶
This section is empty.
Types ¶
type AllValidatorsResponse ¶
type AllValidatorsResponse struct {
Data []ValidatorResponseEntry
}
type BeaconNodeClient ¶
type BeaconNodeClient 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 }
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 MockBeaconClient ¶
type MockBeaconClient struct { MockSyncStatus *SyncStatusPayloadData MockSyncStatusErr error MockProposerDuties *ProposerDutiesResponse MockProposerDutiesErr error MockFetchValidatorsErr error ResponseDelay time.Duration // contains filtered or unexported fields }
func NewMockBeaconClient ¶
func NewMockBeaconClient() *MockBeaconClient
func (*MockBeaconClient) AddValidator ¶
func (c *MockBeaconClient) AddValidator(entry ValidatorResponseEntry)
func (*MockBeaconClient) CurrentSlot ¶
func (c *MockBeaconClient) CurrentSlot() (uint64, error)
func (*MockBeaconClient) FetchValidators ¶
func (c *MockBeaconClient) FetchValidators(headSlot uint64) (map[types.PubkeyHex]ValidatorResponseEntry, error)
func (*MockBeaconClient) GetProposerDuties ¶
func (c *MockBeaconClient) GetProposerDuties(epoch uint64) (*ProposerDutiesResponse, error)
func (*MockBeaconClient) GetURI ¶
func (c *MockBeaconClient) GetURI() string
func (*MockBeaconClient) IsValidator ¶
func (c *MockBeaconClient) IsValidator(pubkey types.PubkeyHex) bool
func (*MockBeaconClient) NumValidators ¶
func (c *MockBeaconClient) NumValidators() uint64
func (*MockBeaconClient) SetValidators ¶
func (c *MockBeaconClient) SetValidators(validatorSet map[types.PubkeyHex]ValidatorResponseEntry)
func (*MockBeaconClient) SubscribeToHeadEvents ¶
func (c *MockBeaconClient) SubscribeToHeadEvents(slotC chan HeadEventData)
func (*MockBeaconClient) SyncStatus ¶
func (c *MockBeaconClient) SyncStatus() (*SyncStatusPayloadData, error)
type ProdBeaconClient ¶
type ProdBeaconClient struct {
// contains filtered or unexported fields
}
func NewProdBeaconClient ¶
func NewProdBeaconClient(log *logrus.Entry, beaconURI string) *ProdBeaconClient
func (*ProdBeaconClient) CurrentSlot ¶
func (c *ProdBeaconClient) CurrentSlot() (uint64, error)
func (*ProdBeaconClient) FetchValidators ¶
func (c *ProdBeaconClient) FetchValidators(headSlot uint64) (map[types.PubkeyHex]ValidatorResponseEntry, error)
func (*ProdBeaconClient) GetBlock ¶
func (c *ProdBeaconClient) GetBlock() (*GetBlockResponse, error)
GetBlock returns the latest block - https://ethereum.github.io/beacon-APIs/#/Beacon/getBlockV2
func (*ProdBeaconClient) GetHeader ¶
func (c *ProdBeaconClient) GetHeader() (*GetHeaderResponse, error)
GetHeader returns the latest header - https://ethereum.github.io/beacon-APIs/#/Beacon/getBlockHeader
func (*ProdBeaconClient) GetProposerDuties ¶
func (c *ProdBeaconClient) GetProposerDuties(epoch uint64) (*ProposerDutiesResponse, error)
GetProposerDuties returns proposer duties for every slot in this epoch https://ethereum.github.io/beacon-APIs/#/Validator/getProposerDuties
func (*ProdBeaconClient) GetURI ¶
func (c *ProdBeaconClient) GetURI() string
func (*ProdBeaconClient) SubscribeToHeadEvents ¶
func (c *ProdBeaconClient) SubscribeToHeadEvents(slotC chan HeadEventData)
func (*ProdBeaconClient) SyncStatus ¶
func (c *ProdBeaconClient) 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"`
}