Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { RPC SyncRequest(ctx context.Context, rpcReq *RPCRequest) (rpcRes *RPCResponse, err error) }
Backend performs communication with a backend
func NewRPCClientWithOption ¶ added in v1.1.8
func NewRPCClientWithOption(client *resty.Client, options RPCClientOptions) Backend
NewRPCClientWithOption Constructor
type RPCClient ¶
type RPCClient struct {
// contains filtered or unexported fields
}
func (*RPCClient) SyncRequest ¶
func (rc *RPCClient) SyncRequest(ctx context.Context, rpcReq *RPCRequest) (rpcRes *RPCResponse, err error)
SyncRequest sends an individual RPC request to the backend (always over HTTP currently), and waits synchronously for the response, or an error.
In all return paths *including error paths* the RPCResponse is populated so the caller has an RPC structure to send back to the front-end caller.
type RPCClientOptions ¶ added in v1.1.8
type RPCClientOptions struct {
MaxConcurrentRequest int64
}
type RPCError ¶
type RPCError struct { Code int64 `json:"code"` Message string `json:"message"` Data fftypes.JSONAny `json:"data,omitempty"` }
func NewRPCError ¶ added in v1.1.11
type RPCRequest ¶
type RPCResponse ¶
type RPCResponse struct { JSONRpc string `json:"jsonrpc"` ID *fftypes.JSONAny `json:"id"` Result *fftypes.JSONAny `json:"result,omitempty"` Error *RPCError `json:"error,omitempty"` // Only for subscription notifications Method string `json:"method,omitempty"` Params *fftypes.JSONAny `json:"params,omitempty"` }
func RPCErrorResponse ¶
func RPCErrorResponse(err error, id *fftypes.JSONAny, code RPCCode) *RPCResponse
func (*RPCResponse) Message ¶
func (r *RPCResponse) Message() string
type RPCSubscriptionNotification ¶ added in v1.1.11
type Subscription ¶ added in v1.1.11
type WebSocketRPCClient ¶ added in v1.1.11
type WebSocketRPCClient interface { RPC Subscribe(ctx context.Context, params ...interface{}) (sub Subscription, error *RPCError) Subscriptions() []Subscription UnsubscribeAll(ctx context.Context) (error *RPCError) Connect(ctx context.Context) error Close() }
WebSocketRPCClient performs communication over a websocket with an Ethereum JSON/RPC endpoint
- Manages websocket connect/reconnect with keepalive etc. - Manages subscriptions with a local ID, so they re-established automatically after reconnect - Allows synchronous exchange over the WebSocket so you don't have to maintain a separate HTTP connection too
func NewWSRPCClient ¶ added in v1.1.11
func NewWSRPCClient(wsConf *wsclient.WSConfig) WebSocketRPCClient
NewRPCClient Constructor