executionclient

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 14 Imported by: 2

Documentation

Overview

Package executionclient implements functions for interacting with Ethereum execution clients.

Index

Constants

View Source
const (
	DefaultConnectionTimeout           = 10 * time.Second
	DefaultReconnectionInitialInterval = 1 * time.Second
	DefaultReconnectionMaxInterval     = 64 * time.Second
	DefaultFollowDistance              = 8
	DefaultHistoricalLogsBatchSize     = 5000
)

Variables

View Source
var (
	ErrClosed        = fmt.Errorf("closed")
	ErrNotConnected  = fmt.Errorf("not connected")
	ErrBadInput      = fmt.Errorf("bad input")
	ErrNothingToSync = errors.New("nothing to sync")
)

Functions

This section is empty.

Types

type BlockLogs

type BlockLogs struct {
	BlockNumber uint64
	Logs        []ethtypes.Log
}

BlockLogs holds a block's number and it's logs.

func PackLogs

func PackLogs(logs []ethtypes.Log) []BlockLogs

PackLogs packs logs into []BlockLogs by their block number.

type ExecutionClient

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

ExecutionClient represents a client for interacting with Ethereum execution client.

func New

func New(ctx context.Context, nodeAddr string, contractAddr ethcommon.Address, opts ...Option) (*ExecutionClient, error)

New creates a new instance of ExecutionClient.

func (*ExecutionClient) BlockByNumber added in v1.2.2

func (ec *ExecutionClient) BlockByNumber(ctx context.Context, blockNumber *big.Int) (*ethtypes.Block, error)

func (*ExecutionClient) Close

func (ec *ExecutionClient) Close() error

Close shuts down ExecutionClient.

func (*ExecutionClient) FetchHistoricalLogs

func (ec *ExecutionClient) FetchHistoricalLogs(ctx context.Context, fromBlock uint64) (logs <-chan BlockLogs, errors <-chan error, err error)

FetchHistoricalLogs retrieves historical logs emitted by the contract starting from fromBlock.

func (*ExecutionClient) Filterer

func (ec *ExecutionClient) Filterer() (*contract.ContractFilterer, error)

func (*ExecutionClient) Healthy

func (ec *ExecutionClient) Healthy(ctx context.Context) error

Healthy returns if execution client is currently healthy: responds to requests and not in the syncing state.

func (*ExecutionClient) StreamLogs

func (ec *ExecutionClient) StreamLogs(ctx context.Context, fromBlock uint64) <-chan BlockLogs

StreamLogs subscribes to events emitted by the contract.

type ExecutionOptions

type ExecutionOptions struct {
	Addr              string        `yaml:"ETH1Addr" env:"ETH_1_ADDR" env-required:"true" env-description:"Execution client WebSocket address"`
	ConnectionTimeout time.Duration `` /* 131-byte string literal not displayed */
}

ExecutionOptions contains config configurations related to Ethereum execution client.

type Option

type Option func(*ExecutionClient)

Option defines an ExecutionClient configuration option.

func WithConnectionTimeout

func WithConnectionTimeout(timeout time.Duration) Option

WithConnectionTimeout sets timeout for network connection to eth1 node.

func WithFollowDistance

func WithFollowDistance(offset uint64) Option

WithFollowDistance sets finalization offset. It defines how many blocks in the past the latest block we want to process is.

func WithLogBatchSize

func WithLogBatchSize(size uint64) Option

WithLogBatchSize sets log batch size.

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger enables logging.

func WithMetrics

func WithMetrics(metrics metrics) Option

WithMetrics enables reporting metrics.

func WithReconnectionInitialInterval

func WithReconnectionInitialInterval(interval time.Duration) Option

WithReconnectionInitialInterval sets initial reconnection interval.

func WithReconnectionMaxInterval

func WithReconnectionMaxInterval(interval time.Duration) Option

WithReconnectionMaxInterval sets max reconnection interval.

Jump to

Keyboard shortcuts

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