multi

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIncorrectType = errors.New("incorrect response type")

ErrIncorrectType is returned when the multi client obtain a response type it is not expecting.

Functions

func New

func New(ctx context.Context, params ...Parameter) (consensusclient.Service, error)

New creates a new Ethereum 2 client with multiple endpoints. The endpoints are periodiclaly checked to see if they are active, and requests will retry a different client if the currently active client fails to respond.

Types

type Parameter

type Parameter interface {
	// contains filtered or unexported methods
}

Parameter is the interface for service parameters.

func WithAddresses

func WithAddresses(addresses []string) Parameter

WithAddresses sets the addresses of clients to add to the multi list.

func WithAllowDelayedStart added in v0.20.0

func WithAllowDelayedStart(allowDelayedStart bool) Parameter

WithAllowDelayedStart allows the service to start even if the client is unavailable.

func WithClients

func WithClients(clients []consensusclient.Service) Parameter

WithClients sets the pre-existing clients to add to the multi list.

func WithEnforceJSON added in v0.19.0

func WithEnforceJSON(enforceJSON bool) Parameter

WithEnforceJSON forces all requests and responses to be in JSON, not sending or requesting SSZ.

func WithExtraHeaders added in v0.16.6

func WithExtraHeaders(headers map[string]string) Parameter

WithExtraHeaders sets additional headers to be sent with each HTTP request.

func WithLogLevel

func WithLogLevel(logLevel zerolog.Level) Parameter

WithLogLevel sets the log level for the module.

func WithMonitor

func WithMonitor(monitor metrics.Service) Parameter

WithMonitor sets the monitor for the service.

func WithName added in v0.20.0

func WithName(name string) Parameter

WithName sets the name for the multiclient.

func WithTimeout

func WithTimeout(timeout time.Duration) Parameter

WithTimeout sets the timeout for client requests.

type Service

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

Service handles multiple Ethereum 2 clients.

func (*Service) Address

func (s *Service) Address() string

Address returns the address of the client.

func (*Service) AggregateAttestation

func (s *Service) AggregateAttestation(ctx context.Context,
	opts *api.AggregateAttestationOpts,
) (
	*api.Response[*phase0.Attestation],
	error,
)

AggregateAttestation fetches the aggregate attestation given an attestation.

func (*Service) AttestationData

func (s *Service) AttestationData(ctx context.Context,
	opts *api.AttestationDataOpts,
) (
	*api.Response[*phase0.AttestationData],
	error,
)

AttestationData fetches the attestation data for the given slot and committee index.

func (*Service) AttestationPool

func (s *Service) AttestationPool(ctx context.Context,
	opts *api.AttestationPoolOpts,
) (
	*api.Response[[]*phase0.Attestation],
	error,
)

AttestationPool obtains the attestation pool for a given slot.

func (*Service) AttesterDuties

func (s *Service) AttesterDuties(ctx context.Context,
	opts *api.AttesterDutiesOpts,
) (
	*api.Response[[]*apiv1.AttesterDuty],
	error,
)

AttesterDuties obtains attester duties. If validatorIndicess is nil it will return all duties for the given epoch.

func (*Service) BeaconBlockHeader

func (s *Service) BeaconBlockHeader(ctx context.Context,
	opts *api.BeaconBlockHeaderOpts,
) (
	*api.Response[*apiv1.BeaconBlockHeader],
	error,
)

BeaconBlockHeader provides the block header of a given block ID.

func (*Service) BeaconBlockRoot

func (s *Service) BeaconBlockRoot(ctx context.Context,
	opts *api.BeaconBlockRootOpts,
) (
	*api.Response[*phase0.Root],
	error,
)

BeaconBlockRoot fetches a block's root given a block ID.

func (*Service) BeaconCommittees

func (s *Service) BeaconCommittees(ctx context.Context,
	opts *api.BeaconCommitteesOpts,
) (
	*api.Response[[]*apiv1.BeaconCommittee],
	error,
)

BeaconCommittees fetches all beacon committees for the epoch at the given state.

func (*Service) BeaconState

BeaconState fetches a beacon state.

func (*Service) BeaconStateRoot

func (s *Service) BeaconStateRoot(ctx context.Context,
	opts *api.BeaconStateRootOpts,
) (
	*api.Response[*phase0.Root],
	error,
)

BeaconStateRoot fetches a beacon state root given a state ID.

func (*Service) BlobSidecars added in v0.19.0

func (s *Service) BlobSidecars(ctx context.Context,
	opts *api.BlobSidecarsOpts,
) (*api.Response[[]*deneb.BlobSidecar],
	error,
)

BlobSidecars fetches the blob sidecars given options.

func (*Service) DepositContract

func (s *Service) DepositContract(ctx context.Context,
	opts *api.DepositContractOpts,
) (
	*api.Response[*apiv1.DepositContract],
	error,
)

DepositContract provides details of the Ethereum 1 deposit contract for the chain.

func (*Service) Domain

func (s *Service) Domain(ctx context.Context,
	domainType phase0.DomainType,
	epoch phase0.Epoch,
) (
	phase0.Domain,
	error,
)

Domain provides a domain for a given domain type at a given epoch.

func (*Service) Events

func (s *Service) Events(ctx context.Context,
	topics []string,
	handler consensusclient.EventHandlerFunc,
) error

Events feeds requested events with the given topics to the supplied handler.

func (*Service) FarFutureEpoch

func (s *Service) FarFutureEpoch(ctx context.Context) (phase0.Epoch, error)

FarFutureEpoch provides the far future epoch of the chain.

func (*Service) Finality

func (s *Service) Finality(ctx context.Context, opts *api.FinalityOpts) (*api.Response[*apiv1.Finality], error)

Finality provides the finality given a state ID.

func (*Service) Fork

func (s *Service) Fork(ctx context.Context,
	opts *api.ForkOpts,
) (
	*api.Response[*phase0.Fork],
	error,
)

Fork fetches fork information for the given state.

func (*Service) ForkChoice added in v0.21.2

func (s *Service) ForkChoice(ctx context.Context,
	opts *api.ForkChoiceOpts,
) (
	*api.Response[*apiv1.ForkChoice],
	error,
)

ForkChoice fetches all current fork choice context.

func (*Service) ForkSchedule

func (s *Service) ForkSchedule(ctx context.Context,
	opts *api.ForkScheduleOpts,
) (
	*api.Response[[]*phase0.Fork],
	error,
)

ForkSchedule provides details of past and future changes in the chain's fork version.

func (*Service) Genesis

func (s *Service) Genesis(ctx context.Context,
	opts *api.GenesisOpts,
) (
	*api.Response[*apiv1.Genesis],
	error,
)

Genesis provides the genesis for the chain.

func (*Service) GenesisDomain added in v0.15.5

func (s *Service) GenesisDomain(ctx context.Context,
	domainType phase0.DomainType,
) (
	phase0.Domain,
	error,
)

GenesisDomain provides a domain for a given domain type.

func (*Service) GenesisTime deprecated

func (s *Service) GenesisTime(ctx context.Context) (time.Time, error)

GenesisTime provides the genesis time of the chain.

Deprecated: use Genesis().

func (*Service) IsActive added in v0.20.0

func (s *Service) IsActive() bool

IsActive returns true if the client is active. The service is considered active if at least one client is synced.

func (*Service) IsSynced added in v0.20.0

func (s *Service) IsSynced() bool

IsSynced returns true if the client is synced. The service is considered synced if at least one client is synced.

func (*Service) Name

func (*Service) Name() string

Name returns the name of the client implementation.

func (*Service) NodePeers added in v0.19.0

func (s *Service) NodePeers(ctx context.Context, opts *api.NodePeersOpts) (*api.Response[[]*apiv1.Peer], error)

NodePeers provides the peers of the node.

func (*Service) NodeSyncing

func (s *Service) NodeSyncing(ctx context.Context,
	opts *api.NodeSyncingOpts,
) (
	*api.Response[*apiv1.SyncState],
	error,
)

NodeSyncing provides the syncing information for the node.

func (*Service) NodeVersion

func (s *Service) NodeVersion(ctx context.Context, opts *api.NodeVersionOpts) (*api.Response[string], error)

NodeVersion provides the version information of the node.

func (*Service) Proposal added in v0.19.0

func (s *Service) Proposal(ctx context.Context,
	opts *api.ProposalOpts,
) (
	*api.Response[*api.VersionedProposal],
	error,
)

Proposal fetches a proposal for signing.

func (*Service) ProposerDuties

func (s *Service) ProposerDuties(ctx context.Context,
	opts *api.ProposerDutiesOpts,
) (
	*api.Response[[]*apiv1.ProposerDuty],
	error,
)

ProposerDuties obtains proposer duties for the given epoch. If validatorIndices is empty all duties are returned, otherwise only matching duties are returned.

func (*Service) SignedBeaconBlock

func (s *Service) SignedBeaconBlock(ctx context.Context,
	opts *api.SignedBeaconBlockOpts,
) (
	*api.Response[*spec.VersionedSignedBeaconBlock],
	error,
)

SignedBeaconBlock fetches a signed beacon block given a block ID.

func (*Service) SlotDuration deprecated

func (s *Service) SlotDuration(ctx context.Context) (time.Duration, error)

SlotDuration provides the duration of a slot of the chain.

Deprecated: use Spec().

func (*Service) SlotsPerEpoch deprecated

func (s *Service) SlotsPerEpoch(ctx context.Context) (uint64, error)

SlotsPerEpoch provides the slots per epoch of the chain.

Deprecated: use Spec().

func (*Service) Spec

func (s *Service) Spec(ctx context.Context,
	opts *api.SpecOpts,
) (
	*api.Response[map[string]any],
	error,
)

Spec provides the spec information of the chain.

func (*Service) SubmitAggregateAttestations

func (s *Service) SubmitAggregateAttestations(ctx context.Context,
	aggregateAndProofs []*phase0.SignedAggregateAndProof,
) error

SubmitAggregateAttestations submits aggregate attestations.

func (*Service) SubmitAttestations

func (s *Service) SubmitAttestations(ctx context.Context,
	attestations []*phase0.Attestation,
) error

SubmitAttestations submits attestations.

func (*Service) SubmitBeaconBlock deprecated

func (s *Service) SubmitBeaconBlock(ctx context.Context, block *spec.VersionedSignedBeaconBlock) error

SubmitBeaconBlock submits a beacon block.

Deprecated: this will not work from the deneb hard-fork onwards. Use SubmitProposal() instead.

func (*Service) SubmitBeaconCommitteeSubscriptions

func (s *Service) SubmitBeaconCommitteeSubscriptions(ctx context.Context,
	subscriptions []*api.BeaconCommitteeSubscription,
) error

SubmitBeaconCommitteeSubscriptions subscribes to beacon committees.

func (*Service) SubmitBlindedBeaconBlock deprecated added in v0.11.6

func (s *Service) SubmitBlindedBeaconBlock(ctx context.Context, block *api.VersionedSignedBlindedBeaconBlock) error

SubmitBlindedBeaconBlock submits a blinded beacon block.

Deprecated: this will not work from the deneb hard-fork onwards. Use SubmitBlindedProposal() instead.

func (*Service) SubmitProposal added in v0.19.0

func (s *Service) SubmitProposal(ctx context.Context,
	opts *api.SubmitProposalOpts,
) error

SubmitProposal submits a beacon block.

func (*Service) SubmitProposalPreparations added in v0.11.6

func (s *Service) SubmitProposalPreparations(ctx context.Context,
	preparations []*apiv1.ProposalPreparation,
) error

SubmitProposalPreparations provides the beacon node with information required if a proposal for the given validators shows up in the next epoch.

func (*Service) SubmitSyncCommitteeContributions added in v0.9.2

func (s *Service) SubmitSyncCommitteeContributions(ctx context.Context,
	contributionAndProofs []*altair.SignedContributionAndProof,
) error

SubmitSyncCommitteeContributions submits sync committee contributions.

func (*Service) SubmitSyncCommitteeMessages

func (s *Service) SubmitSyncCommitteeMessages(ctx context.Context,
	messages []*altair.SyncCommitteeMessage,
) error

SubmitSyncCommitteeMessages submits sync committee messages.

func (*Service) SubmitSyncCommitteeSubscriptions

func (s *Service) SubmitSyncCommitteeSubscriptions(ctx context.Context,
	subscriptions []*api.SyncCommitteeSubscription,
) error

SubmitSyncCommitteeSubscriptions subscribes to sync committees.

func (*Service) SubmitValidatorRegistrations added in v0.12.0

func (s *Service) SubmitValidatorRegistrations(ctx context.Context, registrations []*api.VersionedSignedValidatorRegistration) error

SubmitValidatorRegistrations submits a validator registration.

func (*Service) SubmitVoluntaryExit

func (s *Service) SubmitVoluntaryExit(ctx context.Context, voluntaryExit *phase0.SignedVoluntaryExit) error

SubmitVoluntaryExit submits a voluntary exit.

func (*Service) SyncCommittee added in v0.9.2

func (s *Service) SyncCommittee(ctx context.Context, opts *api.SyncCommitteeOpts) (*api.Response[*apiv1.SyncCommittee], error)

SyncCommittee fetches the sync committee for the given state.

func (*Service) SyncCommitteeContribution added in v0.9.2

func (s *Service) SyncCommitteeContribution(ctx context.Context,
	opts *api.SyncCommitteeContributionOpts,
) (
	*api.Response[*altair.SyncCommitteeContribution],
	error,
)

SyncCommitteeContribution provides a sync committee contribution.

func (*Service) SyncCommitteeDuties

func (s *Service) SyncCommitteeDuties(ctx context.Context,
	opts *api.SyncCommitteeDutiesOpts,
) (
	*api.Response[[]*apiv1.SyncCommitteeDuty],
	error,
)

SyncCommitteeDuties obtains attester duties. If validatorIndicess is nil it will return all duties for the given epoch.

func (*Service) TargetAggregatorsPerCommittee deprecated

func (s *Service) TargetAggregatorsPerCommittee(ctx context.Context) (uint64, error)

TargetAggregatorsPerCommittee provides the target number of aggregators for each attestation committee.

Deprecated: Use Spec().

func (*Service) ValidatorBalances

func (s *Service) ValidatorBalances(ctx context.Context,
	opts *api.ValidatorBalancesOpts,
) (
	*api.Response[map[phase0.ValidatorIndex]phase0.Gwei],
	error,
)

ValidatorBalances provides the validator balances for a given state.

func (*Service) Validators

func (s *Service) Validators(ctx context.Context,
	opts *api.ValidatorsOpts,
) (
	*api.Response[map[phase0.ValidatorIndex]*apiv1.Validator],
	error,
)

Validators provides the validators, with their balance and status, for a given state.

func (*Service) VoluntaryExitPool added in v0.18.2

func (s *Service) VoluntaryExitPool(ctx context.Context,
	opts *api.VoluntaryExitPoolOpts,
) (
	*api.Response[[]*phase0.SignedVoluntaryExit],
	error,
)

VoluntaryExitPool obtains the voluntary exit pool.

Jump to

Keyboard shortcuts

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