duties

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Number of slots per epoch
	SlotsPerEpoch = 32

	// Number of seconds per beacon slot
	SecondsPerSlot = 12

	// Timestamp of the beacon chain genesis
	BeaconChainGenesis = 1606824023
)

Variables

This section is empty.

Functions

func GetRequest

func GetRequest(endpoint string, target interface{}) error

Performs a GET request and unmarshals the JSON with the given target type

func PostRequest

func PostRequest(endpoint string, target interface{}, data interface{}) error

Performs a POST request and unmarshals the JSON wwith the given target type

func Start

func Start(opts ...Option) error

Types

type AttesterDutiesResponse

type AttesterDutiesResponse struct {
	DependentRoot       string          `json:"dependent_root"`
	Data                []*AttesterDuty `json:"data"`
	ExecutionOptimistic bool            `json:"execution_optimistic"`
}

type AttesterDuty

type AttesterDuty struct {
	Pubkey                 string `json:"pubkey"`
	CommitteeIndex         string `json:"committee_index"`
	CommitteeLength        string `json:"committee_length"`
	CommitteesAtSlot       string `json:"committees_at_slot"`
	ValidatorCommiteeIndex string `json:"validator_committee_index"`
	ValidatorIndex         uint64 `json:"validator_index,string"`
	Slot                   uint64 `json:"slot,string"`
}

type BeaconBlockHeader

type BeaconBlockHeader struct {
	ProposerIndex string `json:"proposer_index"`
	ParentRoot    string `json:"parent_root"`
	StateRoot     string `json:"state_root"`
	BodyRoot      string `json:"body_root"`
	Slot          uint64 `json:"slot,string"`
}

type Option

type Option func(d *ValidatorDuties) error

Option type that will operate on the validator duties and modify its state

func WithBeaconNodeEndpoint

func WithBeaconNodeEndpoint(endpoint string) Option

func WithTimezone

func WithTimezone(timezone *time.Location) Option

func WithValidator

func WithValidator(validator uint64) Option

type ProposerDutiesResponse

type ProposerDutiesResponse struct {
	DependentRoot       string          `json:"dependent_root"`
	Data                []*ProposerDuty `json:"data"`
	ExecutionOptimistic bool            `json:"execution_optimistic"`
}

type ProposerDuty

type ProposerDuty struct {
	Pubkey         string `json:"pubkey"`
	ValidatorIndex uint64 `json:"validator_index,string"`
	Slot           uint64 `json:"slot,string"`
}

type SignedBeaconBlockHeader

type SignedBeaconBlockHeader struct {
	Signature string            `json:"signature"`
	Message   BeaconBlockHeader `json:"message"`
}

type SignedBeaconBlockHeaderContainer

type SignedBeaconBlockHeaderContainer struct {
	Root      string                  `json:"root"`
	Header    SignedBeaconBlockHeader `json:"header"`
	Canonical bool                    `json:"canonical"`
}

type SignedBeaconBlockResponse

type SignedBeaconBlockResponse struct {
	Data                SignedBeaconBlockHeaderContainer `json:"data"`
	ExecutionOptimistic bool                             `json:"execution_optimistic"`
	Finalized           bool                             `json:"finalized"`
}

type SyncCommitteeDutiesResponse

type SyncCommitteeDutiesResponse struct {
	DependentRoot       string               `json:"dependent_root"`
	Data                []*SyncCommitteeDuty `json:"data"`
	ExecutionOptimistic bool                 `json:"execution_optimistic"`
}

type SyncCommitteeDuty

type SyncCommitteeDuty struct {
	Pubkey                        string   `json:"pubkey"`
	ValidatorSyncCommitteeIndices []string `json:"validator_sync_committee_indices"`
	ValidatorIndex                uint64   `json:"validator_index,string"`
}

type ValidatorDuties

type ValidatorDuties struct {
	Timezone           *time.Location
	CurrEpochDuties    *ValidatorDutyEpoch
	NextEpochDuties    *ValidatorDutyEpoch
	BeaconNodeEndpoint string
	Validator          uint64
}

func New

func New(opts ...Option) (*ValidatorDuties, error)

Create a new instance of validator duties

func (*ValidatorDuties) DisplayDuties

func (d *ValidatorDuties) DisplayDuties()

func (*ValidatorDuties) ProcessAttesterDuties

func (d *ValidatorDuties) ProcessAttesterDuties(epoch uint64) (uint64, error)

Processes an attester duty response

func (*ValidatorDuties) ProcessProposerDuties

func (d *ValidatorDuties) ProcessProposerDuties(epoch uint64) ([]uint64, error)

Processes a proposer duty response

func (*ValidatorDuties) ProcessSyncCommitteeDuties

func (d *ValidatorDuties) ProcessSyncCommitteeDuties(epoch uint64) (bool, error)

Processes sync committee duty response

func (*ValidatorDuties) QueryAttesterDuties

func (d *ValidatorDuties) QueryAttesterDuties(epoch uint64) (*AttesterDutiesResponse, error)

Queries the duties of the attester for a given epoch

func (*ValidatorDuties) QueryBeaconHeadBlock

func (d *ValidatorDuties) QueryBeaconHeadBlock() (*SignedBeaconBlockResponse, error)

Queries the head block of the beacon chain

func (*ValidatorDuties) QueryProposerDuties

func (d *ValidatorDuties) QueryProposerDuties(epoch uint64) (*ProposerDutiesResponse, error)

Queries the duties of the proposer for a given epoch

func (*ValidatorDuties) QuerySyncCommitteeDuties

func (d *ValidatorDuties) QuerySyncCommitteeDuties(
	epoch uint64,
) (*SyncCommitteeDutiesResponse, error)

Queries the sync committee duties for a given epoch

type ValidatorDutyEpoch

type ValidatorDutyEpoch struct {
	ProposalSlots   []uint64
	AttestationSlot uint64
	Epoch           uint64
	SyncCommittee   bool
}

Contains the duties of a validator for a given epoch

Jump to

Keyboard shortcuts

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