rpc

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InternalServerError = -32603
	ParseError          = -32700
	InvalidRequest      = -32600

	RequestTimeout = 3 * time.Second
)

Variables

This section is empty.

Functions

func CreateRPCError

func CreateRPCError(isBatch bool, reqRPCBody RPCRequest, reqRPCBodies []RPCRequest, code int, message string) interface{}

CreateRPCError returns rpc errors for appropriate request ids

func IsBatch

func IsBatch(reqBody []byte) bool

IsBatch returns if request contains batch rpc requests

func SendRequestToNode

func SendRequestToNode(isBatch bool, nodeID string, reqBody []byte) ([]byte, error)

SendRequestToNode routes request to node and checks response

Types

type RPCError

type RPCError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type RPCRequest

type RPCRequest struct {
	JSONRPC string      `json:"jsonrpc"`
	ID      uint64      `json:"id"`
	Method  string      `json:"method,omitempty"`
	Params  interface{} `json:"params,omitempty"`
}

type RPCResponse

type RPCResponse struct {
	JSONRPC string           `json:"jsonrpc"`
	ID      uint64           `json:"id"`
	Result  *json.RawMessage `json:"result,omitempty"`
	Error   *RPCError        `json:"error,omitempty"`
}

func CheckBatchRPCResponse

func CheckBatchRPCResponse(body []byte) ([]RPCResponse, error)

CheckBatchRPCResponse checks for errors in batch rpc response

func CheckSingleRPCResponse

func CheckSingleRPCResponse(body []byte) (RPCResponse, error)

CheckSingleRPCResponse checks for errors in non batch rpc response

Jump to

Keyboard shortcuts

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