rpc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 22 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustServeGRPC

func MustServeGRPC(ctx context.Context, wg *sync.WaitGroup, config Config, store store.Readable)

MustServeGRPC starts gRPC service and wait for graceful shutdown.

func MustServeRPC

func MustServeRPC(ctx context.Context, wg *sync.WaitGroup, config Config, store store.Readable)

MustServeRPC starts RPC service and wait for graceful shutdown.

Types

type Api

type Api struct {
	store.Readable
	// contains filtered or unexported fields
}

Api is the eth RPC implementation.

func NewApi

func NewApi(store store.Readable, lruCacheSize int) *Api

func (*Api) GetBlock

func (api *Api) GetBlock(bhon types.BlockHashOrNumber, isFull bool) (types.Lazy[*ethTypes.Block], error)

func (*Api) GetTrace

func (api *Api) GetTrace(txHash common.Hash, index uint) (types.Lazy[*ethTypes.LocalizedTrace], error)

func (*Api) GetTransactionByHash

func (api *Api) GetTransactionByHash(txHash common.Hash) (types.Lazy[*ethTypes.TransactionDetail], error)

func (*Api) GetTransactionByIndex

func (api *Api) GetTransactionByIndex(bhon types.BlockHashOrNumber, txIndex uint32) (types.Lazy[*ethTypes.TransactionDetail], error)

func (*Api) GetTransactionReceipt

func (api *Api) GetTransactionReceipt(txHash common.Hash) (types.Lazy[*ethTypes.Receipt], error)

func (*Api) GetTransactionTraces

func (api *Api) GetTransactionTraces(txHash common.Hash) (types.Lazy[[]ethTypes.LocalizedTrace], error)

type ApiProto

type ApiProto struct {
	pb.UnimplementedEthServer
	// contains filtered or unexported fields
}

ApiProto is the eth gRPC implementation.

func NewApiProto

func NewApiProto(api *Api) *ApiProto

func (*ApiProto) GetBlock

func (api *ApiProto) GetBlock(ctx context.Context, req *pb.GetBlockRequest) (*pb.DataResponse, error)

func (*ApiProto) GetBlockReceipts

func (api *ApiProto) GetBlockReceipts(ctx context.Context, req *pb.BlockId) (*pb.DataResponse, error)

func (*ApiProto) GetBlockTraces

func (api *ApiProto) GetBlockTraces(ctx context.Context, req *pb.BlockId) (*pb.DataResponse, error)

func (*ApiProto) GetBlockTransactionCount

func (api *ApiProto) GetBlockTransactionCount(ctx context.Context, req *pb.BlockId) (*pb.GetBlockTransactionCountResponse, error)

func (*ApiProto) GetTransactionByHash

func (api *ApiProto) GetTransactionByHash(ctx context.Context, req *pb.TransactionId) (*pb.DataResponse, error)

func (*ApiProto) GetTransactionByIndex

func (api *ApiProto) GetTransactionByIndex(ctx context.Context, req *pb.GetTransactionByIndexRequest) (*pb.DataResponse, error)

func (*ApiProto) GetTransactionReceipt

func (api *ApiProto) GetTransactionReceipt(ctx context.Context, req *pb.TransactionId) (*pb.DataResponse, error)

func (*ApiProto) GetTransactionTraces

func (api *ApiProto) GetTransactionTraces(ctx context.Context, req *pb.TransactionId) (*pb.DataResponse, error)

type Client

type Client struct {
	*providers.MiddlewarableProvider
	// contains filtered or unexported fields
}

Client is the RPC client to interact with RPC server.

func NewClient

func NewClient(url string, option ...providers.Option) (*Client, error)

NewClient creates a new client instance.

func (*Client) GetBlock

func (c *Client) GetBlock(bhon types.BlockHashOrNumber, isFull bool) (types.Lazy[*ethTypes.Block], error)

func (*Client) GetBlockReceipts

func (c *Client) GetBlockReceipts(bhon types.BlockHashOrNumber) (types.Lazy[[]ethTypes.Receipt], error)

func (*Client) GetBlockTraces

func (c *Client) GetBlockTraces(bhon types.BlockHashOrNumber) (types.Lazy[[]ethTypes.LocalizedTrace], error)

func (*Client) GetBlockTransactionCount

func (c *Client) GetBlockTransactionCount(bhon types.BlockHashOrNumber) (int64, error)

func (*Client) GetTrace

func (c *Client) GetTrace(txHash common.Hash, index uint) (types.Lazy[*ethTypes.LocalizedTrace], error)

func (*Client) GetTransactionByHash

func (c *Client) GetTransactionByHash(txHash common.Hash) (types.Lazy[*ethTypes.TransactionDetail], error)

func (*Client) GetTransactionByIndex

func (c *Client) GetTransactionByIndex(bhon types.BlockHashOrNumber, txIndex uint32) (types.Lazy[*ethTypes.TransactionDetail], error)

func (*Client) GetTransactionReceipt

func (c *Client) GetTransactionReceipt(txHash common.Hash) (types.Lazy[*ethTypes.Receipt], error)

func (*Client) GetTransactionTraces

func (c *Client) GetTransactionTraces(txHash common.Hash) (types.Lazy[[]ethTypes.LocalizedTrace], error)

func (*Client) String

func (c *Client) String() string

String returns the URL of RPC server.

type ClientProto

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

func NewClientProto

func NewClientProto(url string, timeout ...time.Duration) (*ClientProto, error)

func (*ClientProto) GetBlock

func (c *ClientProto) GetBlock(bhon types.BlockHashOrNumber, isFull bool) (types.Lazy[*ethTypes.Block], error)

func (*ClientProto) GetBlockReceipts

func (c *ClientProto) GetBlockReceipts(bhon types.BlockHashOrNumber) (types.Lazy[[]ethTypes.Receipt], error)

func (*ClientProto) GetBlockTraces

func (c *ClientProto) GetBlockTraces(bhon types.BlockHashOrNumber) (types.Lazy[[]ethTypes.LocalizedTrace], error)

func (*ClientProto) GetBlockTransactionCount

func (c *ClientProto) GetBlockTransactionCount(bhon types.BlockHashOrNumber) (int64, error)

func (*ClientProto) GetTrace

func (c *ClientProto) GetTrace(txHash common.Hash, index uint) (types.Lazy[*ethTypes.LocalizedTrace], error)

func (*ClientProto) GetTransactionByHash

func (c *ClientProto) GetTransactionByHash(txHash common.Hash) (types.Lazy[*ethTypes.TransactionDetail], error)

func (*ClientProto) GetTransactionByIndex

func (c *ClientProto) GetTransactionByIndex(bhon types.BlockHashOrNumber, txIndex uint32) (types.Lazy[*ethTypes.TransactionDetail], error)

func (*ClientProto) GetTransactionReceipt

func (c *ClientProto) GetTransactionReceipt(txHash common.Hash) (types.Lazy[*ethTypes.Receipt], error)

func (*ClientProto) GetTransactionTraces

func (c *ClientProto) GetTransactionTraces(txHash common.Hash) (types.Lazy[[]ethTypes.LocalizedTrace], error)

func (*ClientProto) String

func (c *ClientProto) String() string

type Config

type Config struct {
	Endpoint     string   `default:":38545"`
	Cors         []string `default:"[*]"`
	VirtualHosts []string `default:"[*]"`
	JwtSecretHex string   // without 0x prefix

	LruCacheSize int `default:"4096"`

	Proto struct {
		Endpoint       string `default:":48545"`
		MaxMessageSize int    `default:"67108864"` // 64MB
	}
}

func DefaultConfig

func DefaultConfig() (config Config)

type Interface

type Interface interface {
	// GetBlock returns block for the given block hash or number. If not found, returns nil.
	GetBlock(bhon types.BlockHashOrNumber, isFull bool) (types.Lazy[*ethTypes.Block], error)

	// GetBlockTransactionCount returns the transaction count for the given block hash or number. If not found, returns -1.
	GetBlockTransactionCount(bhon types.BlockHashOrNumber) (int64, error)

	// GetTransactionByHash returns transaction for the given transaction hash. If not found, returns nil.
	GetTransactionByHash(txHash common.Hash) (types.Lazy[*ethTypes.TransactionDetail], error)

	// GetTransactionByIndex returns transaction for the given block hash or number along with transaction index. If not found, returns nil.
	GetTransactionByIndex(bhon types.BlockHashOrNumber, txIndex uint32) (types.Lazy[*ethTypes.TransactionDetail], error)

	// GetTransactionReceipt returns receipt for the given transaction hash. If not found, returns nil.
	GetTransactionReceipt(txHash common.Hash) (types.Lazy[*ethTypes.Receipt], error)

	// GetBlockReceipts returns all block receipts for the given block hash or number. If not found, returns nil.
	GetBlockReceipts(bhon types.BlockHashOrNumber) (types.Lazy[[]ethTypes.Receipt], error)

	// GetTransactionTraces returns all transaction traces for the given transaction hash. If not found, returns nil.
	GetTransactionTraces(txHash common.Hash) (types.Lazy[[]ethTypes.LocalizedTrace], error)

	// GetBlockTraces returns all block traces for the given block hash or number. If not found, returns nil.
	GetBlockTraces(bhon types.BlockHashOrNumber) (types.Lazy[[]ethTypes.LocalizedTrace], error)

	// GetTrace returns single trace for the given transaction hash at specified index. If not found, returns nil.
	GetTrace(txHash common.Hash, index uint) (types.Lazy[*ethTypes.LocalizedTrace], error)
}
var NotFoundImpl Interface = notFoundImpl{}

type Metrics

type Metrics struct{}

func (*Metrics) GetBlockHitCache

func (m *Metrics) GetBlockHitCache(isFull bool) metricsUtil.Percentage

func (*Metrics) GetBlockIsFull

func (m *Metrics) GetBlockIsFull() metricsUtil.Percentage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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