rpc

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2024 License: MIT Imports: 3 Imported by: 5

Documentation

Overview

Package rpc provides a parser for the RPC API requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBatch

func IsBatch(body []byte) bool

IsBatch determines if a request is batch. This method's implementation is borrowed from rpc/json.go in ethereum-go where it is unexported.

func IsNullResponse added in v0.13.0

func IsNullResponse(body []byte) bool

IsNullResponse checks if the result field in the JSON-RPC response is null

Types

type Request

type Request struct {
	ID      int               `json:"id"`
	Method  string            `json:"method"`
	JSONRPC string            `json:"jsonrpc,omitempty"`
	Params  []json.RawMessage `json:"params"`
}

Request is a raw rpc request format.

type Requests

type Requests []Request

Requests is a list or rpc requests.

func ParseRPCPayload

func ParseRPCPayload(body []byte) (_ Requests, err error)

ParseRPCPayload parses a raw rpc request body and returns a list of rpc requests.

func (Requests) ByID

func (r Requests) ByID(id int) *Request

ByID will get an rpc requet by the id.

func (Requests) Method

func (r Requests) Method() string

Method returns the method of the rpc request.

Jump to

Keyboard shortcuts

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