MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / parse

Method parse

src/rpc/core/rpcserver.cpp:377–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375};
376
377void JSONRequest::parse(const Value& valRequest) {
378 // Parse request
379 if (valRequest.type() != obj_type)
380 throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object");
381
382 const Object& request = valRequest.get_obj();
383
384 // Parse id now so errors from here on will have the id
385 id = find_value(request, "id");
386
387 // Parse method
388 Value valMethod = find_value(request, "method");
389 if (valMethod.type() == null_type)
390 throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method");
391
392 if (valMethod.type() != str_type)
393 throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string");
394
395 strMethod = valMethod.get_str();
396 LogPrint(BCLog::RPC, "ThreadRPCServer method=%s\n", strMethod);
397
398 // Parse params
399 Value valParams = find_value(request, "params");
400 if (valParams.type() == array_type)
401 params = valParams.get_array();
402 else if (valParams.type() == null_type)
403 params = Array();
404 else
405 throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array");
406}
407
408Object JSONRPCExecOne(const Value& req) {
409 Object rpc_result;

Callers 2

JSONRPCExecOneFunction · 0.80
JsonRPCHandlerFunction · 0.80

Calls 2

JSONRPCErrorFunction · 0.85
typeMethod · 0.80

Tested by

no test coverage detected