| 181 | } |
| 182 | |
| 183 | std::vector<UniValue> JSONRPCProcessBatchReply(const UniValue& in) |
| 184 | { |
| 185 | if (!in.isArray()) { |
| 186 | throw std::runtime_error("Batch must be an array"); |
| 187 | } |
| 188 | const size_t num {in.size()}; |
| 189 | std::vector<UniValue> batch(num); |
| 190 | for (const UniValue& rec : in.getValues()) { |
| 191 | if (!rec.isObject()) { |
| 192 | throw std::runtime_error("Batch member must be an object"); |
| 193 | } |
| 194 | size_t id = rec["id"].get_int(); |
| 195 | if (id >= num) { |
| 196 | throw std::runtime_error("Batch member id is larger than batch size"); |
| 197 | } |
| 198 | batch[id] = rec; |
| 199 | } |
| 200 | return batch; |
| 201 | } |
| 202 | |
| 203 | void JSONRPCRequest::parse(const UniValue& valRequest) |
| 204 | { |
no test coverage detected