rpc: rename RawParams to Params in Raw, add comments
We've got parameters here and usually we name them Raw when they're represented by json.RawMessage which is not the case here, so make it a bit more friendly (the type itself is only used in client internals, so rename is not a huge problem).
This commit is contained in:
parent
9aecfb7c94
commit
113cb0fac3
3 changed files with 25 additions and 13 deletions
|
@ -176,7 +176,7 @@ func (c *Client) performRequest(method string, p request.RawParams, v interface{
|
||||||
var r = request.Raw{
|
var r = request.Raw{
|
||||||
JSONRPC: request.JSONRPCVersion,
|
JSONRPC: request.JSONRPCVersion,
|
||||||
Method: method,
|
Method: method,
|
||||||
RawParams: p.Values,
|
Params: p.Values,
|
||||||
ID: c.getNextRequestID(),
|
ID: c.getNextRequestID(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -256,7 +256,7 @@ writeloop:
|
||||||
break writeloop
|
break writeloop
|
||||||
}
|
}
|
||||||
if err := c.ws.WriteJSON(req); err != nil {
|
if err := c.ws.WriteJSON(req); err != nil {
|
||||||
connCloseErr = fmt.Errorf("failed to write JSON request (%s / %d): %w", req.Method, len(req.RawParams), err)
|
connCloseErr = fmt.Errorf("failed to write JSON request (%s / %d): %w", req.Method, len(req.Params), err)
|
||||||
break writeloop
|
break writeloop
|
||||||
}
|
}
|
||||||
case <-pingTicker.C:
|
case <-pingTicker.C:
|
||||||
|
|
|
@ -32,15 +32,27 @@ func NewRawParams(vals ...interface{}) RawParams {
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
// Raw represents JSON-RPC request on the Client side.
|
|
||||||
type Raw struct {
|
|
||||||
JSONRPC string `json:"jsonrpc"`
|
|
||||||
Method string `json:"method"`
|
|
||||||
RawParams []interface{} `json:"params"`
|
|
||||||
ID uint64 `json:"id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
// Raw represents JSON-RPC request. It's generic enough to be used in many
|
||||||
|
// generic JSON-RPC communication scenarios, yet at the same time it's
|
||||||
|
// tailored for NeoGo RPC Client needs.
|
||||||
|
Raw struct {
|
||||||
|
// JSONRPC is the protocol version, only valid when it contains JSONRPCVersion.
|
||||||
|
JSONRPC string `json:"jsonrpc"`
|
||||||
|
// Method is the method being called.
|
||||||
|
Method string `json:"method"`
|
||||||
|
// Params is a set of method-specific parameters passed to the call. They
|
||||||
|
// can be anything as long as they can be marshaled to JSON correctly and
|
||||||
|
// used by the method implementation on the server side. While JSON-RPC
|
||||||
|
// technically allows it to be an object, all Neo calls expect params
|
||||||
|
// to be an array.
|
||||||
|
Params []interface{} `json:"params"`
|
||||||
|
// ID is an identifier associated with this request. JSON-RPC itself allows
|
||||||
|
// any strings to be used for it as well, but NeoGo RPC client uses numeric
|
||||||
|
// identifiers.
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
// BlockFilter is a wrapper structure for the block event filter. The only
|
// BlockFilter is a wrapper structure for the block event filter. The only
|
||||||
// allowed filter is primary index.
|
// allowed filter is primary index.
|
||||||
BlockFilter struct {
|
BlockFilter struct {
|
||||||
|
|
Loading…
Reference in a new issue