ethmulticlient

package
v1.3.51 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EthBlockNumberBatchElem

func EthBlockNumberBatchElem() rpc.BatchElem

EthBlockNumberBatchElem returns an initialized BatchElem for the eth_blockNumber call.

Types

type EVMClient

type EVMClient interface {
	// BatchCallContext is a batch call to an EVM.
	BatchCallContext(ctx context.Context, calls []rpc.BatchElem) error
}

EVMClient is an interface that abstracts the evm client.

func NewGoEthereumClientImpl

func NewGoEthereumClientImpl(
	ctx context.Context,
	apiMetrics metrics.APIMetrics,
	api config.APIConfig,
	index int,
) (EVMClient, error)

NewGoEthereumClientImpl creates an EVMClient via a config.Endpoint. This includes optional authentication via a specified http header key and value.

func NewMultiRPCClient

func NewMultiRPCClient(
	logger *zap.Logger,
	api config.APIConfig,
	clients []EVMClient,
) EVMClient

NewMultiRPCClient returns a new MultiRPCClient.

func NewMultiRPCClientFromEndpoints

func NewMultiRPCClientFromEndpoints(
	ctx context.Context,
	logger *zap.Logger,
	api config.APIConfig,
	apiMetrics metrics.APIMetrics,
) (EVMClient, error)

NewMultiRPCClientFromEndpoints creates a MultiRPCClient from config endpoints.

type GoEthereumClientImpl

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

GoEthereumClientImpl is a go-ethereum client implementation using the go-ethereum RPC library.

func (*GoEthereumClientImpl) BatchCallContext

func (c *GoEthereumClientImpl) BatchCallContext(ctx context.Context, calls []rpc.BatchElem) error

BatchCallContext sends all given requests as a single batch and waits for the server to return a response for all of them. The wait duration is bounded by the context's deadline.

In contrast to CallContext, BatchCallContext only returns errors that have occurred while sending the request. Any error specific to a request is reported through the Error field of the corresponding BatchElem.

Note that batch calls may not be executed atomically on the server side.

type MultiRPCClient

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

MultiRPCClient implements the EVMClient interface by calling multiple underlying EVMClients and choosing the best response. Specifically, it calls eth_blockNumber on each client and chooses the response with the highest block number.

func (*MultiRPCClient) BatchCallContext

func (m *MultiRPCClient) BatchCallContext(ctx context.Context, batchElems []rpc.BatchElem) error

BatchCallContext injects a call to eth_blockNumber, and makes batch calls to the underlying EVMClients. It returns the response that has the greatest height from the eth_blockNumber call. An error is returned only when no client was able to successfully provide a height or errored when sending the BatchCall.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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