rpctypes

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventSubscriber

type EventSubscriber interface {
	Subscribe(ctx context.Context, subscriber string, query tmpubsub.Query, out chan<- interface{}) error
	Unsubscribe(ctx context.Context, subscriber string, query tmpubsub.Query) error
	UnsubscribeAll(ctx context.Context, subscriber string) error
}

EventSubscriber mirros tendermint/tendermint/types.EventBusSubscriber

type JSONRPCIntID

type JSONRPCIntID int

JSONRPCIntID a wrapper for JSON-RPC integer IDs

type JSONRPCStringID

type JSONRPCStringID string

JSONRPCStringID a wrapper for JSON-RPC string IDs

type RPCError

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

	TxResult *TxResult `json:"tx_result,omitempty"`
}

func (RPCError) Error

func (err RPCError) Error() string

type RPCRequest

type RPCRequest struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      jsonrpcid       `json:"id"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params"` // must be map[string]interface{} or []interface{}
}

func ArrayToRequest

func ArrayToRequest(cdc *amino.Codec, id jsonrpcid, method string, params []interface{}) (RPCRequest, error)

func MapToRequest

func MapToRequest(cdc *amino.Codec, id jsonrpcid, method string, params map[string]interface{}) (RPCRequest, error)

func NewRPCRequest

func NewRPCRequest(id jsonrpcid, method string, params json.RawMessage) RPCRequest

func (RPCRequest) String

func (req RPCRequest) String() string

func (*RPCRequest) UnmarshalJSON

func (request *RPCRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON custom JSON unmarshalling due to jsonrpcid being string or int

type RPCResponse

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

func NewRPCErrorResponse

func NewRPCErrorResponse(id jsonrpcid, code int, msg string, data string) RPCResponse

func NewRPCSuccessResponse

func NewRPCSuccessResponse(cdc *amino.Codec, id jsonrpcid, res interface{}) RPCResponse

func RPCInternalError

func RPCInternalError(id jsonrpcid, err error) RPCResponse

func RPCInvalidParamsError

func RPCInvalidParamsError(id jsonrpcid, err error) RPCResponse

func RPCInvalidRequestError

func RPCInvalidRequestError(id jsonrpcid, err error) RPCResponse

func RPCMethodNotFoundError

func RPCMethodNotFoundError(id jsonrpcid) RPCResponse

func RPCParseError

func RPCParseError(id jsonrpcid, err error) RPCResponse

func RPCServerError

func RPCServerError(id jsonrpcid, err error) RPCResponse

func (RPCResponse) String

func (resp RPCResponse) String() string

func (*RPCResponse) UnmarshalJSON

func (response *RPCResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON custom JSON unmarshalling due to jsonrpcid being string or int

type TxError

type TxError struct {
	Code uint32 `json:"code"`
	Log  string `json:"log"`
}

func (TxError) Error

func (err TxError) Error() string

type TxResult

type TxResult struct {
	Code uint32 `json:"code"`
	Log  string `json:"log"`
}

type WSRPCConnection

type WSRPCConnection interface {
	GetRemoteAddr() string
	WriteRPCResponse(resp RPCResponse)
	TryWriteRPCResponse(resp RPCResponse) bool
	GetEventSubscriber() EventSubscriber
	Codec() *amino.Codec
}

*wsConnection implements this interface.

type WSRPCContext

type WSRPCContext struct {
	Request RPCRequest
	WSRPCConnection
}

websocket-only RPCFuncs take this as the first parameter.

Jump to

Keyboard shortcuts

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