rpc

package
v0.0.0-...-f409b5d Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RPC

type RPC struct {
	ChainID int64
	URL     string
	Height  int64
	Status  Status
	// contains filtered or unexported fields
}

func NewRPC

func NewRPC(chainID int64, url string) *RPC

type RPCs

type RPCs []*RPC

func NewRPCs

func NewRPCs(chainID int64, urls []string) RPCs

func (RPCs) GetRandomRPC

func (rpcs RPCs) GetRandomRPC(num int, exclude RPCs) RPCs

GetRandomRPC returns a random RPC from the list of RPCs, which the status is OK and the height is the highest as possible

func (RPCs) RefreshRpcStatus

func (rpcs RPCs) RefreshRpcStatus()

func (RPCs) SendRequest

func (rpcs RPCs) SendRequest(body []byte, numberOfRPCs int, exclude RPCs, httpProxy ...string) (response []byte, origins RPCs, err error)

SendRequest sends JSON RPC request by selecting a random RPC from the list of good status RPCs

func (RPCs) StopRefreshRpcStatus

func (rpcs RPCs) StopRefreshRpcStatus()

type Status

type Status string
const (
	Unknown Status = "Unknown"
	OK      Status = "OK"
	Down    Status = "Down"
)

Jump to

Keyboard shortcuts

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