mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-14 05:41:21 +00:00
check for request ID after receiving it
This commit is contained in:
committed by
Ethan Buchman
parent
e36c79f713
commit
7fadde0b37
@ -75,7 +75,7 @@ func NewJSONRPCClient(remote string) *JSONRPCClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *JSONRPCClient) Call(method string, params map[string]interface{}, result interface{}) (interface{}, error) {
|
func (c *JSONRPCClient) Call(method string, params map[string]interface{}, result interface{}) (interface{}, error) {
|
||||||
request, err := types.MapToRequest("", method, params)
|
request, err := types.MapToRequest("jsonrpc-client", method, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ func (c *WSClient) Send(ctx context.Context, request types.RPCRequest) error {
|
|||||||
|
|
||||||
// Call the given method. See Send description.
|
// Call the given method. See Send description.
|
||||||
func (c *WSClient) Call(ctx context.Context, method string, params map[string]interface{}) error {
|
func (c *WSClient) Call(ctx context.Context, method string, params map[string]interface{}) error {
|
||||||
request, err := types.MapToRequest("", method, params)
|
request, err := types.MapToRequest("ws-client", method, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ func (c *WSClient) Call(ctx context.Context, method string, params map[string]in
|
|||||||
// CallWithArrayParams the given method with params in a form of array. See
|
// CallWithArrayParams the given method with params in a form of array. See
|
||||||
// Send description.
|
// Send description.
|
||||||
func (c *WSClient) CallWithArrayParams(ctx context.Context, method string, params []interface{}) error {
|
func (c *WSClient) CallWithArrayParams(ctx context.Context, method string, params []interface{}) error {
|
||||||
request, err := types.ArrayToRequest("", method, params)
|
request, err := types.ArrayToRequest("ws-client", method, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,11 @@ func makeJSONRPCHandler(funcMap map[string]*RPCFunc, logger log.Logger) http.Han
|
|||||||
WriteRPCResponseHTTP(w, types.RPCParseError("", errors.Wrap(err, "Error unmarshalling request")))
|
WriteRPCResponseHTTP(w, types.RPCParseError("", errors.Wrap(err, "Error unmarshalling request")))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// A Notification is a Request object without an "id" member.
|
||||||
|
// The Server MUST NOT reply to a Notification, including those that are within a batch request.
|
||||||
|
if request.ID == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
if len(r.URL.Path) > 1 {
|
if len(r.URL.Path) > 1 {
|
||||||
WriteRPCResponseHTTP(w, types.RPCInvalidRequestError(request.ID, errors.Errorf("Path %s is invalid", r.URL.Path)))
|
WriteRPCResponseHTTP(w, types.RPCInvalidRequestError(request.ID, errors.Errorf("Path %s is invalid", r.URL.Path)))
|
||||||
return
|
return
|
||||||
@ -513,6 +518,12 @@ func (wsc *wsConnection) readRoutine() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A Notification is a Request object without an "id" member.
|
||||||
|
// The Server MUST NOT reply to a Notification, including those that are within a batch request.
|
||||||
|
if request.ID == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Now, fetch the RPCFunc and execute it.
|
// Now, fetch the RPCFunc and execute it.
|
||||||
|
|
||||||
rpcFunc := wsc.funcMap[request.Method]
|
rpcFunc := wsc.funcMap[request.Method]
|
||||||
|
Reference in New Issue
Block a user