beaconclient

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package beaconclient defines a service that interacts with a beacon node via a gRPC client to listen for streamed blocks, attestations, and to submit proposer/attester slashings to the node in case they are detected.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainFetcher

type ChainFetcher interface {
	ChainHead(ctx context.Context) (*ethpb.ChainHead, error)
}

ChainFetcher defines a struct which can retrieve chain information from a beacon node such as the latest chain head.

type Config

type Config struct {
	BeaconProvider        string
	BeaconCert            string
	SlasherDB             db.Database
	ProposerSlashingsFeed *event.Feed
	AttesterSlashingsFeed *event.Feed
}

Config options for the beaconclient service.

type Notifier

type Notifier interface {
	BlockFeed() *event.Feed
	AttestationFeed() *event.Feed
	ClientReadyFeed() *event.Feed
}

Notifier defines a struct which exposes event feeds regarding beacon blocks, attestations, and more information received from a beacon node.

type Service

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

Service struct for the beaconclient service of the slasher.

func NewBeaconClientService

func NewBeaconClientService(ctx context.Context, cfg *Config) *Service

NewBeaconClientService instantiation.

func (*Service) AttestationFeed

func (bs *Service) AttestationFeed() *event.Feed

AttestationFeed returns a feed other services in slasher can subscribe to attestations received via the beacon node through gRPC.

func (*Service) BlockFeed

func (bs *Service) BlockFeed() *event.Feed

BlockFeed returns a feed other services in slasher can subscribe to blocks received via the beacon node through gRPC.

func (*Service) ChainHead

func (bs *Service) ChainHead(
	ctx context.Context,
) (*ethpb.ChainHead, error)

ChainHead requests the latest beacon chain head from a beacon node via gRPC.

func (*Service) ClientReadyFeed

func (bs *Service) ClientReadyFeed() *event.Feed

ClientReadyFeed returns a feed other services in slasher can subscribe to to indicate when the gRPC connection is ready.

func (*Service) RequestHistoricalAttestations

func (bs *Service) RequestHistoricalAttestations(
	ctx context.Context,
	epoch uint64,
) ([]*ethpb.IndexedAttestation, error)

RequestHistoricalAttestations requests all indexed attestations for a given epoch from a beacon node via gRPC.

func (*Service) Start

func (bs *Service) Start()

Start the main runtime of the beaconclient service, initializing a gRPC client connection with a beacon node, listening for streamed blocks/attestations, and submitting slashing operations after they are detected by other services in the slasher.

func (*Service) Status

func (bs *Service) Status() error

Status returns an error if there exists a gRPC connection error in the service.

func (*Service) Stop

func (bs *Service) Stop() error

Stop the beacon client service by closing the gRPC connection.

Jump to

Keyboard shortcuts

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