clients

package
v0.0.0-...-6c8d3ff Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClientURLNotSet         error = errors.New("configuration client URL not set")
	ErrConcurrentClientsNotSet error = errors.New("configuration amount of concurrent clients is not set")
)

Error messages

Functions

This section is empty.

Types

type EthClient

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

EthClient represents a load-balanced Ethereum client. It maintains a list of underlying Ethereum clients and provides methods to interact with the Ethereum network.

func NewEthClients

func NewEthClients(ctx context.Context, opts []options.Node) (*EthClient, error)

NewEthClient creates a new EthClient with the given context and options. It concurrently dials the specified number of Ethereum clients and returns an EthClient that load balances requests among them. If any error occurs during the dialing of the Ethereum clients, it is returned.

func (*EthClient) Close

func (c *EthClient) Close()

Close closes all the underlying Ethereum clients.

func (*EthClient) GetClient

func (c *EthClient) GetClient(chainId *big.Int) *ethclient.Client

GetClient returns the next Ethereum client in a round-robin fashion.

func (*EthClient) GetNetworkID

func (c *EthClient) GetNetworkID(ctx context.Context, chainId *big.Int) (*big.Int, error)

GetNetworkID retrieves the network ID from one of the underlying Ethereum clients.

func (*EthClient) Len

func (c *EthClient) Len() int

Len returns the number of underlying Ethereum clients.

Jump to

Keyboard shortcuts

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