rpc

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JsonRpcRequest

type JsonRpcRequest struct {
	Id      any         `json:"id"`
	JSONRpc string      `json:"jsonrpc,omitempty"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params,omitempty"`
}

func MustUnmarshalJsonRpcRequest

func MustUnmarshalJsonRpcRequest(data []byte) *JsonRpcRequest

type JsonRpcResponse

type JsonRpcResponse struct {
	Id      any                   `json:"id"`
	JSONRpc string                `json:"jsonrpc,omitempty"`
	Error   *JsonRpcResponseError `json:"error,omitempty"`
	Result  interface{}           `json:"result,omitempty"`
}

func Error

func Error(id any, code int, msg string) *JsonRpcResponse

func ErrorInvalidParams

func ErrorInvalidParams(id any, msg string) *JsonRpcResponse

func ErrorInvalidRequest

func ErrorInvalidRequest(id any, msg string) *JsonRpcResponse

func ErrorMethodNotFound

func ErrorMethodNotFound(id any, msg string) *JsonRpcResponse

func ErrorServerError

func ErrorServerError(id any, msg string) *JsonRpcResponse

func NewJsonRpcResponse

func NewJsonRpcResponse(id any, result any, err *JsonRpcResponseError) *JsonRpcResponse

func (*JsonRpcResponse) Marshal

func (r *JsonRpcResponse) Marshal() []byte

type JsonRpcResponseError

type JsonRpcResponseError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    any    `json:"data"`
}

func NewJsonRpcResponseError

func NewJsonRpcResponseError(code int, message string, data any) *JsonRpcResponseError

type Session

type Session struct {
	RequestCtx any
	Method     string
	Path       string
	Chain      string
	Request    *JsonRpcRequest
	RawRequest []byte
	Cfg        config.Config

	Tries            int
	NodeName         string
	IsWriteRpcMethod bool
	// contains filtered or unexported fields
}

func (*Session) Id

func (s *Session) Id() any

func (*Session) Init

func (s *Session) Init() error

func (*Session) IsMaxRetriesExceeded

func (s *Session) IsMaxRetriesExceeded() bool

func (*Session) NewJsonRpcError

func (s *Session) NewJsonRpcError(err error) *JsonRpcResponse

func (*Session) RpcMethod

func (s *Session) RpcMethod() string

func (*Session) RpcParams

func (s *Session) RpcParams() interface{}

func (*Session) SId

func (s *Session) SId() string

Jump to

Keyboard shortcuts

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