| 48 | using std::chrono::microseconds; |
| 49 | |
| 50 | Array GetKeyPrefixArray(const Value &jsonValue) { |
| 51 | auto valueType = jsonValue.type(); |
| 52 | |
| 53 | if (valueType == json_spirit::array_type) { |
| 54 | return jsonValue.get_array(); |
| 55 | } else if (valueType == json_spirit::str_type) { |
| 56 | json_spirit::Value newObj; |
| 57 | try { |
| 58 | json_spirit::read_string_or_throw(jsonValue.get_str(), newObj); |
| 59 | } catch (json_spirit::Error_position &e) { |
| 60 | throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Parse json of key prefix array error! line[%d:%d] %s", |
| 61 | e.line_, e.column_, e.reason_)); |
| 62 | } |
| 63 | auto newObjType = newObj.type(); |
| 64 | if (newObjType == json_spirit::obj_type || newObjType == json_spirit::array_type) { |
| 65 | return newObj.get_array(); |
| 66 | } |
| 67 | } |
| 68 | throw JSONRPCError(RPC_INVALID_PARAMETER, "The contract action args type must be object or array," |
| 69 | " or string of object or array"); |
| 70 | } |
| 71 | |
| 72 | Array GetKeyPrefixArray(const Array ¶ms, uint32_t index) { |
| 73 | return (params.size() > index) ? GetKeyPrefixArray(params[index]) : Array(); |
no test coverage detected