rpcsplitter

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const LoggerTag = "RPCSPLITTER"

Variables

This section is empty.

Functions

func NewServer

func NewServer(opts ...Option) (http.Handler, error)

Types

type Any added in v0.10.0

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

Any stores an argument in its raw form, and it is passed to the RPC server unmodified.

func (Any) MarshalJSON added in v0.10.0

func (t Any) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*Any) UnmarshalJSON added in v0.10.0

func (t *Any) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Option

type Option func(s *server) error

func WithEndpoints

func WithEndpoints(endpoints []string) Option

WithEndpoints options instructs RPC-Splitter to use provided list of Ethereum RPC nodes.

func WithGracefulTimeout

func WithGracefulTimeout(t time.Duration) Option

WithGracefulTimeout sets a timeout for slower endpoints. If the RPC-Splitter gets enough responses to return a valid response, it will wait until the timeout for slower endpoints is exceeded. This will allow slower requests to be gracefully finished, and for endpoints that calculate the median value, it will return a more accurate response.

func WithLogger

func WithLogger(logger log.Logger) Option

WithLogger sets logger.

func WithRequirements

func WithRequirements(minResponses int, maxBlockBehind int) Option

WithRequirements specifies the requirements that must be met in order for responses to be considered valid.

minResponses - minimum number of same responses, ideally this number should be greater than half the number of endpoints provided. For methods that return a gas price or block number, this is the number of non-error responses.

maxBlockBehind - the maximum number of blocks after the last known block. Because some RPC endpoints may be behind others, the RPC-Splitter uses the lowest block number of all responses, but the difference from the last known cannot be less than specified in this parameter.

func WithTotalTimeout

func WithTotalTimeout(t time.Duration) Option

WithTotalTimeout sets the total timeout for all endpoints. When the timeout is exceeded, RPC-Splitter cancels all requests to the endpoints.

type Transport

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

Transport implements the http.RoundTripper interface. It creates a virtual host with RPC Splitter.

func NewTransport

func NewTransport(vhost string, transport http.RoundTripper, opts ...Option) (*Transport, error)

NewTransport returns a new instance of Transport.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the http.RoundTripper interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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