rpc

package
v1.1.12-beta Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: Apache-2.0 Imports: 15 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 GetTransactionParams

func GetTransactionParams(txHash string) []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(ctx context.Context, 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(ctx context.Context, blockNumbers []*big.Int) []GetFullBlockResult

func (*Client) GetLatestBlockNumber

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

func (*Client) GetTransactions

func (rpc *Client) GetTransactions(ctx context.Context, txHashes []string) []GetTransactionsResult

func (*Client) GetURL

func (rpc *Client) GetURL() string

func (*Client) HasCode

func (rpc *Client) HasCode(ctx context.Context, address string) (bool, error)

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[*big.Int, common.RawBlock]) []GetBlocksResult

type GetFullBlockResult

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

type GetTransactionsResult

type GetTransactionsResult struct {
	Error error
	Data  common.Transaction
}

func SerializeTransactions

func SerializeTransactions(chainId *big.Int, transactions []RPCFetchBatchResult[string, common.RawTransaction]) []GetTransactionsResult

type IRPCClient

type IRPCClient interface {
	GetFullBlocks(ctx context.Context, blockNumbers []*big.Int) []GetFullBlockResult
	GetBlocks(ctx context.Context, blockNumbers []*big.Int) []GetBlocksResult
	GetTransactions(ctx context.Context, txHashes []string) []GetTransactionsResult
	GetLatestBlockNumber(ctx context.Context) (*big.Int, error)
	GetChainID() *big.Int
	GetURL() string
	GetBlocksPerRequest() BlocksPerRequestConfig
	IsWebsocket() bool
	SupportsTraceBlock() bool
	HasCode(ctx context.Context, address string) (bool, error)
	Close()
}

func Initialize

func Initialize() (IRPCClient, error)

func InitializeSimpleRPCWithUrl

func InitializeSimpleRPCWithUrl(url string) (IRPCClient, error)

type RPCFetchBatchResult

type RPCFetchBatchResult[K any, T any] struct {
	Key    K
	Error  error
	Result T
}

func RPCFetchInBatches

func RPCFetchInBatches[K any, T any](rpc *Client, ctx context.Context, keys []K, batchSize int, batchDelay int, method string, argsFunc func(K) []interface{}) []RPCFetchBatchResult[K, T]

func RPCFetchSingleBatch

func RPCFetchSingleBatch[K any, T any](rpc *Client, ctx context.Context, keys []K, method string, argsFunc func(K) []interface{}) []RPCFetchBatchResult[K, T]

Jump to

Keyboard shortcuts

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