MCPcopy Create free account
hub / github.com/CPChain/chain / checkReqId

Function checkReqId

api/rpc/json.go:155–167  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
155func 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

Callers 2

parseRequestFunction · 0.85
parseBatchRequestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected