jsonrpc2

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeResponses added in v0.0.4

func DecodeResponses(response []byte) ([]json.RawMessage, error)

DecodeResponses decodes the top level json rpc response for a batched rpc call

func EncodeClientRequest

func EncodeClientRequest(method string, args interface{}, id string) ([]byte, error)

EncodeClientRequest encodes parameters for a JSON-RPC client request.

func EncodeClientRequests added in v0.0.4

func EncodeClientRequests(requests []*JSONRPCRequest) ([]byte, error)

EncodeClientRequests encodes an array of rpc requests

Types

type DecodeError added in v0.0.4

type DecodeError struct {
	Raw []byte
	Err error
}

DecodeError : error returned when failing to decode a response

func (DecodeError) Error added in v0.0.4

func (d DecodeError) Error() string

Error message string

type JSONRPCError

type JSONRPCError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    string `json:"data,omitempty"`
}

JSONRPCError : standard JSONRPC Error

type JSONRPCMessage

type JSONRPCMessage struct {
	Version string          `json:"jsonrpc"`
	ID      string          `json:"id,omitempty"`
	Method  string          `json:"method,omitempty"`
	Params  json.RawMessage `json:"params,omitempty"`
	Error   *JSONRPCError   `json:"error,omitempty"`
	Result  json.RawMessage `json:"result,omitempty"`
	Raw     json.RawMessage `json:"-"`
}

JSONRPCMessage : standard JSONRPC 2 Response

func DecodeResponse

func DecodeResponse(response []byte) (*JSONRPCMessage, error)

DecodeResponse decodes the top level json rpc response for a single rpc call

func (*JSONRPCMessage) HasValidID

func (msg *JSONRPCMessage) HasValidID() bool

func (*JSONRPCMessage) IsNotification

func (msg *JSONRPCMessage) IsNotification() bool

func (*JSONRPCMessage) IsResponse

func (msg *JSONRPCMessage) IsResponse() bool

func (*JSONRPCMessage) String

func (msg *JSONRPCMessage) String() string

func (*JSONRPCMessage) UINTResult

func (msg *JSONRPCMessage) UINTResult() (uint64, error)

UINTResult decods the the result as uint

func (*JSONRPCMessage) ValidID

func (msg *JSONRPCMessage) ValidID() (string, error)

ValidID decods the id if it s valid

type JSONRPCNotification

type JSONRPCNotification struct {
	ID     string          `json:"subscription"`
	Result json.RawMessage `json:"result"`
}

JSONRPCNotification : standard JSONRPC 2 Notification

func (*JSONRPCNotification) ValidID

func (msg *JSONRPCNotification) ValidID() (string, error)

ValidID decods the id if it s valid

type JSONRPCRequest

type JSONRPCRequest struct {
	Version string      `json:"jsonrpc"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params"`
	ID      string      `json:"id"`
}

JSONRPCRequest standard JSONRPC 2 Request

func BuildRequest added in v0.0.4

func BuildRequest(method string, args interface{}) *JSONRPCRequest

BuildRequest creates a new RPC request struct with a random ID

func NewRequest added in v0.0.4

func NewRequest(method string, args interface{}, id string) *JSONRPCRequest

NewRequest creates a new RPC requests struct with all attributes required

func (*JSONRPCRequest) Encode added in v0.0.4

func (req *JSONRPCRequest) Encode() ([]byte, error)

Encode returns the byte array json encoded value

Jump to

Keyboard shortcuts

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