checkReqId returns an error when the given reqId isn't valid for RPC method calls. valid id's are strings, numbers or null
(reqId json.RawMessage)
| 153 | // checkReqId returns an error when the given reqId isn't valid for RPC method calls. |
| 154 | // valid id's are strings, numbers or null |
| 155 | func checkReqId(reqId json.RawMessage) error { |
| 156 | if len(reqId) == 0 { |
| 157 | return fmt.Errorf("missing request id") |
| 158 | } |
| 159 | if _, err := strconv.ParseFloat(string(reqId), 64); err == nil { |
| 160 | return nil |
| 161 | } |
| 162 | var str string |
| 163 | if err := json.Unmarshal(reqId, &str); err == nil { |
| 164 | return nil |
| 165 | } |
| 166 | return fmt.Errorf("invalid request id") |
| 167 | } |
| 168 | |
| 169 | // parseRequest will parse a single request from the given RawMessage. It will return |
| 170 | // the parsed request, an indication if the request was a batch or an error when |
no outgoing calls
no test coverage detected