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