Documentation
¶
Index ¶
- func EthBlockNumberBatchElem() rpc.BatchElem
- type EVMClient
- func NewGoEthereumClientImpl(ctx context.Context, apiMetrics metrics.APIMetrics, api config.APIConfig, ...) (EVMClient, error)
- func NewMultiRPCClient(logger *zap.Logger, api config.APIConfig, clients []EVMClient) EVMClient
- func NewMultiRPCClientFromEndpoints(ctx context.Context, logger *zap.Logger, api config.APIConfig, ...) (EVMClient, error)
- type GoEthereumClientImpl
- type MultiRPCClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EthBlockNumberBatchElem ¶
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 ¶
NewMultiRPCClient returns a new MultiRPCClient.
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 ¶
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 ¶
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.