rpc

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_BLOCKS_PER_REQUEST   = 1000
	DEFAULT_LOGS_PER_REQUEST     = 100
	DEFAULT_TRACES_PER_REQUEST   = 100
	DEFAULT_RECEIPTS_PER_REQUEST = 250
)

TODO: we should detect this automatically

Variables

This section is empty.

Functions

func ExtractFunctionSelector

func ExtractFunctionSelector(s string) string

*

  • Extracts the function selector (first 4 bytes) from a transaction input.

func GetBlockReceiptsParams

func GetBlockReceiptsParams(blockNum *big.Int) []interface{}

func GetBlockWithTransactionsParams

func GetBlockWithTransactionsParams(blockNum *big.Int) []interface{}

func GetBlockWithoutTransactionsParams

func GetBlockWithoutTransactionsParams(blockNum *big.Int) []interface{}

func GetLogsParams

func GetLogsParams(blockNum *big.Int) []interface{}

func TraceBlockParams

func TraceBlockParams(blockNum *big.Int) []interface{}

Types

type BlocksPerRequestConfig

type BlocksPerRequestConfig struct {
	Blocks   int
	Logs     int
	Traces   int
	Receipts int
}

func GetBlockPerRequestConfig

func GetBlockPerRequestConfig() BlocksPerRequestConfig

type Client

type Client struct {
	RPCClient *gethRpc.Client
	EthClient *ethclient.Client
	// contains filtered or unexported fields
}

func (*Client) Close

func (rpc *Client) Close()

func (*Client) GetBlocks

func (rpc *Client) GetBlocks(blockNumbers []*big.Int) []GetBlocksResult

func (*Client) GetBlocksPerRequest

func (rpc *Client) GetBlocksPerRequest() BlocksPerRequestConfig

func (*Client) GetChainID

func (rpc *Client) GetChainID() *big.Int

func (*Client) GetFullBlocks

func (rpc *Client) GetFullBlocks(blockNumbers []*big.Int) []GetFullBlockResult

func (*Client) GetLatestBlockNumber

func (rpc *Client) GetLatestBlockNumber() (*big.Int, error)

func (*Client) GetURL

func (rpc *Client) GetURL() string

func (*Client) IsWebsocket

func (rpc *Client) IsWebsocket() bool

func (*Client) SupportsTraceBlock

func (rpc *Client) SupportsTraceBlock() bool

type GetBlocksResult

type GetBlocksResult struct {
	BlockNumber *big.Int
	Error       error
	Data        common.Block
}

func SerializeBlocks

func SerializeBlocks(chainId *big.Int, blocks []RPCFetchBatchResult[common.RawBlock]) []GetBlocksResult

type GetFullBlockResult

type GetFullBlockResult struct {
	BlockNumber *big.Int
	Error       error
	Data        common.BlockData
}

type IRPCClient

type IRPCClient interface {
	GetFullBlocks(blockNumbers []*big.Int) []GetFullBlockResult
	GetBlocks(blockNumbers []*big.Int) []GetBlocksResult
	GetLatestBlockNumber() (*big.Int, error)
	GetChainID() *big.Int
	GetURL() string
	GetBlocksPerRequest() BlocksPerRequestConfig
	IsWebsocket() bool
	SupportsTraceBlock() bool
}

func Initialize

func Initialize() (IRPCClient, error)

type RPCFetchBatchResult

type RPCFetchBatchResult[T any] struct {
	BlockNumber *big.Int
	Error       error
	Result      T
}

func RPCFetchBatch

func RPCFetchBatch[T any](rpc *Client, blockNumbers []*big.Int, method string, argsFunc func(*big.Int) []interface{}) []RPCFetchBatchResult[T]

func RPCFetchInBatches

func RPCFetchInBatches[T any](rpc *Client, blockNumbers []*big.Int, batchSize int, batchDelay int, method string, argsFunc func(*big.Int) []interface{}) []RPCFetchBatchResult[T]

Jump to

Keyboard shortcuts

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