Documentation
¶
Index ¶
- func MinimalRequest(ctx context.Context, cli Client, req PreparedRequest, dest interface{}) (err error)
- func SimpleRequest(ctx context.Context, cli Client, req PreparedRequest, dest interface{}) (exists bool, err error)
- type ApiError
- type ApiPeerId
- type AttesterDuty
- type BasicResponse
- type BeaconBlockHeaderAndInfo
- type BeaconCommitteeSubscribeSignal
- type BlockId
- type BlockIdRoot
- type BlockIdSlot
- type BlockIdStrMode
- type ChainHead
- type Client
- type ClientApiErr
- type ClientErr
- type ClientFunc
- type Codec
- type Committee
- type ConnectionDirection
- type ConnectionState
- type DataWrap
- type DependentAttesterDuties
- type DependentProposerDuty
- type DepositContractResponse
- type ErrorMessage
- type Eth2HttpClient
- type FinalityCheckpoints
- type GenesisResponse
- type HTTPClient
- type HandlerFn
- type Headers
- type HttpResponse
- type HttpRouter
- type IndexedError
- type IndexedErrorMessageItem
- type JSONCodec
- func (JSONCodec) ContentType() []string
- func (JSONCodec) DecodeRequestBody(r io.ReadCloser, dst interface{}) error
- func (JSONCodec) DecodeResponseBody(code uint, r io.ReadCloser, dest interface{}) error
- func (JSONCodec) EncodeRequestBody(w io.Writer, body interface{}) error
- func (JSONCodec) EncodeResponseBody(w io.Writer, data interface{}) error
- type NetworkIdentity
- type NodeVersionResponse
- type Peer
- type PeerCountResponse
- type PlainGET
- type PreparedRequest
- type PreparedResponse
- func RespondAccepted(err error) PreparedResponse
- func RespondBadInput(err error) PreparedResponse
- func RespondBadInputs(msg string, failures []IndexedErrorMessageItem) PreparedResponse
- func RespondInternalError(err error) PreparedResponse
- func RespondNotFound(msg string) PreparedResponse
- func RespondOK(body interface{}) PreparedResponse
- func RespondOKMsg(msg string) PreparedResponse
- func RespondSyncing(msg string) PreparedResponse
- type ProposerDuty
- type Query
- type ReqMethod
- type Request
- type Response
- type RootResponse
- type Route
- type Server
- type SignedBeaconBlock
- type StateId
- type StateIdRoot
- type StateIdSlot
- type StateIdStrMode
- type StatusFilter
- type SyncCommitteeDuty
- type SyncCommitteeSubscribeSignal
- type SyncCommittees
- type SyncingStatus
- type ValidatorBalanceResponse
- type ValidatorId
- type ValidatorIdFilter
- type ValidatorIdIndex
- type ValidatorIdPubkey
- type ValidatorResponse
- type ValidatorStatus
- type VersionedBeaconBlock
- type VersionedBeaconState
- type VersionedSignedBeaconBlock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MinimalRequest ¶
func MinimalRequest(ctx context.Context, cli Client, req PreparedRequest, dest interface{}) (err error)
func SimpleRequest ¶
Types ¶
type ApiPeerId ¶
type ApiPeerId string
Cryptographic hash of a peer’s public key. [Read more](https://docs.libp2p.io/concepts/peer-id/) Further (optional) processing in Go with: https://github.com/libp2p/go-libp2p-core/blob/a39b84ea2e340466d57fdb342c7d62f12957d972/peer/peer.go#L42
type AttesterDuty ¶
type AttesterDuty struct { Pubkey common.BLSPubkey `json:"pubkey"` // Index of validator in validator registry ValidatorIndex common.ValidatorIndex `json:"validator_index"` // The committee index CommitteeIndex common.CommitteeIndex `json:"committee_index"` // Number of validators in committee CommitteeLength view.Uint64View `json:"committee_length"` // Number of committees at the provided slot CommitteesAtSlot view.Uint64View `json:"committees_at_slot"` // Index of validator in committee ValidatorCommitteeIndex view.Uint64View `json:"validator_committee_index"` // The slot at which the validator must attest. Slot common.Slot `json:"slot"` }
type BasicResponse ¶
type BasicResponse struct {
// contains filtered or unexported fields
}
func (*BasicResponse) Body ¶
func (b *BasicResponse) Body() interface{}
func (*BasicResponse) Code ¶
func (b *BasicResponse) Code() uint
func (*BasicResponse) Headers ¶
func (b *BasicResponse) Headers() Headers
type BeaconBlockHeaderAndInfo ¶
type BeaconBlockHeaderAndInfo struct { Root common.Root `json:"root"` Canonical bool `json:"canonical"` Header common.SignedBeaconBlockHeader `json:"header"` }
type BeaconCommitteeSubscribeSignal ¶
type BeaconCommitteeSubscribeSignal struct { ValidatorIndex common.ValidatorIndex `json:"validator_index"` CommitteeIndex common.CommitteeIndex `json:"committee_index"` // Number of committees at the returned slot CommitteesAtSlot view.Uint64View `json:"committees_at_slot"` // Should be slot at which validator is assigned to attest Slot common.Slot `json:"slot"` // Signals to BN that a validator on the VC has been chosen for aggregator role. IsAggregator view.BoolView `json:"is_aggregator"` }
type BlockId ¶
type BlockId interface {
BlockId() string
}
Block identifier Can have different shapes. E.g. BlockHead, BlockIdSlot(123), BlockIdRoot(Root{0x...})
func ParseBlockId ¶
type BlockIdRoot ¶
func (BlockIdRoot) BlockId ¶
func (r BlockIdRoot) BlockId() string
type BlockIdSlot ¶
func (BlockIdSlot) BlockId ¶
func (s BlockIdSlot) BlockId() string
type BlockIdStrMode ¶
type BlockIdStrMode string
const ( BlockHead BlockIdStrMode = "head" BlockGenesis BlockIdStrMode = "genesis" BlockFinalized BlockIdStrMode = "finalized" )
func (BlockIdStrMode) BlockId ¶
func (m BlockIdStrMode) BlockId() string
type ClientApiErr ¶
type ClientApiErr struct {
// contains filtered or unexported fields
}
func (ClientApiErr) Code ¶
func (ce ClientApiErr) Code() uint
type ClientFunc ¶
type ClientFunc func(ctx context.Context, req PreparedRequest) Response
func (ClientFunc) Request ¶
func (fn ClientFunc) Request(ctx context.Context, req PreparedRequest) Response
type Committee ¶
type Committee struct { // Committee index at a slot Index common.CommitteeIndex `json:"index"` // Slot the committee performs duties on Slot common.Slot `json:"slot"` // List of validator indices assigned to this committee Validators []common.ValidatorIndex `json:"validators"` }
type ConnectionDirection ¶
type ConnectionDirection string
const ( ConnectionDirectionInbound ConnectionDirection = "inbound" ConnectionDirectionOutbound ConnectionDirection = "outbound" )
type ConnectionState ¶
type ConnectionState string
const ( ConnectionStateDisconnected ConnectionState = "disconnected" ConnectionStateConnecting ConnectionState = "connecting" ConnectionStateConnected ConnectionState = "connected" ConnectionStateDisconnecting ConnectionState = "disconnecting" )
type DataWrap ¶
type DataWrap struct {
Data interface{} `json:"data"`
}
DataWrap is a util to accommodate responses which are wrapped with a single field container with key "data".
type DependentAttesterDuties ¶
type DependentAttesterDuties struct { // Duties are valid only on the chain with this given block root DependentRoot common.Root `json:"dependent_root"` Data []AttesterDuty `json:"data"` }
Wrapper around the original AttesterDuty response
type DependentProposerDuty ¶
type DependentProposerDuty struct { // Duties are valid only on the chain with this given block root DependentRoot common.Root `json:"dependent_root"` Data []ProposerDuty `json:"data"` }
Wrapper around the original ProposerDuty response
type DepositContractResponse ¶
type DepositContractResponse struct { // Id of Eth1 chain on which contract is deployed. ChainID view.Uint64View `json:"chain_id"` // Hex encoded deposit contract address with 0x prefix Address common.Eth1Address `json:"address"` }
type ErrorMessage ¶
type ErrorMessage struct { // Either specific error code in case of invalid request or http status code CodeValue uint `json:"code"` // Message describing error Message string `json:"message"` // Optional stacktraces, sent when node is in debug mode Stacktraces []string `json:"stacktraces,omitempty"` // Optional list of individual items that have failed Failures []IndexedErrorMessageItem `json:"failures,omitempty"` }
func (*ErrorMessage) Code ¶
func (err *ErrorMessage) Code() uint
func (*ErrorMessage) Error ¶
func (err *ErrorMessage) Error() string
func (*ErrorMessage) IndexedErrors ¶
func (m *ErrorMessage) IndexedErrors() []IndexedErrorMessageItem
type Eth2HttpClient ¶
type Eth2HttpClient struct { Addr string Cli HTTPClient Codec Codec }
func (*Eth2HttpClient) Request ¶
func (cli *Eth2HttpClient) Request(ctx context.Context, req PreparedRequest) Response
type FinalityCheckpoints ¶
type FinalityCheckpoints struct { PreviousJustified common.Checkpoint `json:"previous_justified"` CurrentJustified common.Checkpoint `json:"current_justified"` Finalized common.Checkpoint `json:"finalized"` }
type GenesisResponse ¶
type HttpResponse ¶
func (*HttpResponse) Decode ¶
func (resp *HttpResponse) Decode(dest interface{}) (code uint, err error)
type HttpRouter ¶
type HttpRouter struct { httprouter.Router Codec Codec OnEncodingErr func(error) }
func NewHttpRouter ¶
func NewHttpRouter() *HttpRouter
func (*HttpRouter) AddRoute ¶
func (r *HttpRouter) AddRoute(route Route)
func (*HttpRouter) ServeHTTP ¶
func (r *HttpRouter) ServeHTTP(w http.ResponseWriter, req *http.Request)
type IndexedError ¶
type IndexedError interface {
IndexedErrors() []IndexedErrorMessageItem
}
Optional error enhancement, applicable for API methods that can have a partial success.
type IndexedErrorMessageItem ¶
type JSONCodec ¶
type JSONCodec struct{}
func (JSONCodec) ContentType ¶
func (JSONCodec) DecodeRequestBody ¶
func (JSONCodec) DecodeRequestBody(r io.ReadCloser, dst interface{}) error
func (JSONCodec) DecodeResponseBody ¶
func (JSONCodec) DecodeResponseBody(code uint, r io.ReadCloser, dest interface{}) error
func (JSONCodec) EncodeRequestBody ¶
type NetworkIdentity ¶
type NetworkIdentity struct { PeerID ApiPeerId `json:"peer_id"` // Ethereum node record. [Read more](https://eips.ethereum.org/EIPS/eip-778) ENR string `json:"enr"` // Node's addresses on which eth2 rpc requests are served. [Read more](https://docs.libp2p.io/reference/glossary/#multiaddr) P2PAddresses []string `json:"p2p_addresses"` // Node's addresses on which is listening for discv5 requests. [Read more](https://docs.libp2p.io/reference/glossary/#multiaddr) DiscoveryAddresses []string `json:"discovery_addresses"` // Based on eth2 Metadata object Metadata common.MetaData `json:"metadata"` }
Network identity data, not typed in detail, using libp2p and discv5 dependencies for further processing is optional.
type NodeVersionResponse ¶
type NodeVersionResponse struct {
Version string `json:"version"`
}
type Peer ¶
type Peer struct { PeerID ApiPeerId `json:"peer_id"` ENR string `json:"enr"` LastSeenP2PAddress string `json:"last_seen_p2p_address"` State ConnectionState `json:"state"` Direction ConnectionDirection `json:"direction"` }
type PeerCountResponse ¶
type PeerCountResponse struct { Disconnected view.Uint64View `json:"disconnected"` Connecting view.Uint64View `json:"connecting"` Connected view.Uint64View `json:"connected"` Disconnecting view.Uint64View `json:"disconnecting"` }
Retrieves number of known peers.
type PreparedRequest ¶
type PreparedRequest interface { // The type of request Method() ReqMethod // Body, optional. Returns nil if no body. Only used for PUT/POST methods. Body() interface{} // Path to request, including any path variable contents Path() string // Query params to add to the request, may be nil Query() Query }
func BodyPOST ¶
func BodyPOST(path string, body interface{}) PreparedRequest
func FmtGET ¶
func FmtGET(format string, data ...interface{}) PreparedRequest
func FmtQueryGET ¶
func FmtQueryGET(query Query, format string, data ...interface{}) PreparedRequest
func QueryGET ¶
func QueryGET(query Query, path string) PreparedRequest
type PreparedResponse ¶
type PreparedResponse interface { // Code() uint // body to encode as response, may be nil Body() interface{} // headers to put into the response, may be nil Headers() Headers }
func RespondAccepted ¶
func RespondAccepted(err error) PreparedResponse
func RespondBadInput ¶
func RespondBadInput(err error) PreparedResponse
func RespondBadInputs ¶
func RespondBadInputs(msg string, failures []IndexedErrorMessageItem) PreparedResponse
func RespondInternalError ¶
func RespondInternalError(err error) PreparedResponse
func RespondNotFound ¶
func RespondNotFound(msg string) PreparedResponse
func RespondOK ¶
func RespondOK(body interface{}) PreparedResponse
func RespondOKMsg ¶
func RespondOKMsg(msg string) PreparedResponse
func RespondSyncing ¶
func RespondSyncing(msg string) PreparedResponse
type ProposerDuty ¶
type RootResponse ¶
type Route ¶
type SignedBeaconBlock ¶
type SignedBeaconBlock interface { beacon.OpaqueBlock }
type StateIdRoot ¶
func (StateIdRoot) StateId ¶
func (r StateIdRoot) StateId() string
type StateIdSlot ¶
func (StateIdSlot) StateId ¶
func (s StateIdSlot) StateId() string
type StateIdStrMode ¶
type StateIdStrMode string
const ( StateHead StateIdStrMode = "head" StateGenesis StateIdStrMode = "genesis" StateFinalized StateIdStrMode = "finalized" StateJustified StateIdStrMode = "justified" )
func (StateIdStrMode) StateId ¶
func (m StateIdStrMode) StateId() string
type StatusFilter ¶
type StatusFilter []ValidatorStatus
func (StatusFilter) String ¶
func (sf StatusFilter) String() string
type SyncCommitteeDuty ¶
type SyncCommitteeDuty struct { Pubkey common.BLSPubkey `json:"pubkey"` ValidatorIndex common.ValidatorIndex `json:"validator_index"` ValidatorSyncCommitteeIndices []view.Uint64View `json:"validator_sync_committee_indices"` }
type SyncCommitteeSubscribeSignal ¶
type SyncCommitteeSubscribeSignal struct { ValidatorIndex common.ValidatorIndex `json:"validator_index"` // positions of the validator-index relative to the complete sync committee (a validator can have multiple) SyncCommitteeIndices []view.Uint64View `json:"sync_committee_indices"` UntilEpoch common.Epoch `json:"until_epoch"` }
type SyncCommittees ¶
type SyncCommittees struct { // All of the validator indices in the current sync committee Validators []common.ValidatorIndex `json:"validators"` // Subcommittee slices of the current sync committee ValidatorAggregates [][]common.ValidatorIndex `json:"validator_aggregates"` }
type SyncingStatus ¶
type ValidatorBalanceResponse ¶
type ValidatorBalanceResponse struct { // Index of validator in validator registry. Index common.ValidatorIndex `json:"index"` // Current validator balance in gwei Balance common.Gwei `json:"balance"` }
type ValidatorId ¶
type ValidatorId interface {
ValidatorId() string
}
func ParseValidatorId ¶
func ParseValidatorId(v string) (ValidatorId, error)
type ValidatorIdFilter ¶
type ValidatorIdFilter []ValidatorId
func (ValidatorIdFilter) String ¶
func (vidf ValidatorIdFilter) String() string
type ValidatorIdIndex ¶
type ValidatorIdIndex common.ValidatorIndex
func (ValidatorIdIndex) ValidatorId ¶
func (v ValidatorIdIndex) ValidatorId() string
type ValidatorIdPubkey ¶
func (ValidatorIdPubkey) ValidatorId ¶
func (v ValidatorIdPubkey) ValidatorId() string
type ValidatorResponse ¶
type ValidatorResponse struct { // Index of validator in validator registry. Index common.ValidatorIndex `json:"index"` // Current validator balance in gwei Balance common.Gwei `json:"balance"` // TODO Status ValidatorStatus `json:"status"` // The validator as defined in the registry in the BeaconState Validator phase0.Validator `json:"validator"` }
type ValidatorStatus ¶
type ValidatorStatus string
TODO enum with or without additional values?
const ( ValidatorStatusUnknown ValidatorStatus = "unknown" ValidatorStatusWaitingForEligibility ValidatorStatus = "waiting_for_eligibility" ValidatorStatusWaitingForFinality ValidatorStatus = "waiting_for_finality" ValidatorStatusWaitingInQueue ValidatorStatus = "waiting_in_queue" ValidatorStatusStandbyForActive ValidatorStatus = "standby_for_active" ValidatorStatusActive ValidatorStatus = "active" ValidatorStatusActiveAwaitingVoluntaryExit ValidatorStatus = "active_awaiting_voluntary_exit" ValidatorStatusActiveAwaitingSlashedExit ValidatorStatus = "active_awaiting_slashed_exit" ValidatorStatusExitedVoluntarily ValidatorStatus = "exited_voluntarily" ValidatorStatusExitedSlashed ValidatorStatus = "exited_slashed" ValidatorStatusWithdrawable ValidatorStatus = "withdrawable" ValidatorStatusWithdrawn ValidatorStatus = "withdrawn" )
status names known from lighthouse, differ from spec, TODO
func (ValidatorStatus) String ¶
func (vs ValidatorStatus) String() string
type VersionedBeaconBlock ¶
type VersionedBeaconBlock struct { Version string `json:"version"` // Data is *phase0.BeaconBlock, *altair.BeaconBlock, // *bellatrix.BeaconBlock or *sharding.BeaconBlock. Data common.SpecObj `json:"data"` }
func (*VersionedBeaconBlock) UnmarshalJSON ¶
func (v *VersionedBeaconBlock) UnmarshalJSON(b []byte) error
type VersionedBeaconState ¶
type VersionedBeaconState struct { Version string `json:"version"` // Data is *phase0.BeaconState, *altair.BeaconState, *bellatrix.BeaconState or *sharding.BeaconState. // See the Tree(spec) method to transform into a binary-tree backed state for advanced processing. Data common.SpecObj `json:"data"` }
func (*VersionedBeaconState) Tree ¶
func (v *VersionedBeaconState) Tree(spec *common.Spec) (common.BeaconState, error)
func (*VersionedBeaconState) UnmarshalJSON ¶
func (v *VersionedBeaconState) UnmarshalJSON(b []byte) error
type VersionedSignedBeaconBlock ¶
type VersionedSignedBeaconBlock struct { Version string `json:"version"` // Data is *phase0.SignedBeaconBlock, *altair.SignedBeaconBlock, // *bellatrix.SignedBeaconBlock or *sharding.SignedBeaconBlock. Data SignedBeaconBlock `json:"data"` }
func (*VersionedSignedBeaconBlock) UnmarshalJSON ¶
func (v *VersionedSignedBeaconBlock) UnmarshalJSON(b []byte) error