shh: fix shh_subscribe request parsing for batch requests in jsonrpc api (#14450)

This commit is contained in:
Dominik Hirzel 2017-05-15 09:40:14 +02:00
parent 1f6cec8924
commit 10cd54e924

View file

@ -218,6 +218,8 @@ func parseBatchRequest(incomingMsg json.RawMessage) ([]rpcRequest, bool, Error)
id := &in[i].Id id := &in[i].Id
// shh_subscribe should not be handled in a special way
if !strings.HasPrefix(r.Method, "shh_") {
// subscribe are special, they will always use `subscriptionMethod` as first param in the payload // subscribe are special, they will always use `subscriptionMethod` as first param in the payload
if strings.HasSuffix(r.Method, subscribeMethodSuffix) { if strings.HasSuffix(r.Method, subscribeMethodSuffix) {
requests[i] = rpcRequest{id: id, isPubSub: true} requests[i] = rpcRequest{id: id, isPubSub: true}
@ -236,6 +238,7 @@ func parseBatchRequest(incomingMsg json.RawMessage) ([]rpcRequest, bool, Error)
return nil, true, &invalidRequestError{"Unable to parse (un)subscribe request arguments"} return nil, true, &invalidRequestError{"Unable to parse (un)subscribe request arguments"}
} }
}
if strings.HasSuffix(r.Method, unsubscribeMethodSuffix) { if strings.HasSuffix(r.Method, unsubscribeMethodSuffix) {
requests[i] = rpcRequest{id: id, isPubSub: true, method: r.Method, params: r.Payload} requests[i] = rpcRequest{id: id, isPubSub: true, method: r.Method, params: r.Payload}