| 142 | } |
| 143 | |
| 144 | std::vector<UniValue> JSONRPCProcessBatchReply(const UniValue &in) { |
| 145 | if (!in.isArray()) { |
| 146 | throw std::runtime_error("Batch must be an array"); |
| 147 | } |
| 148 | const size_t num{in.size()}; |
| 149 | std::vector<UniValue> batch(num); |
| 150 | for (const UniValue &rec : in.getValues()) { |
| 151 | if (!rec.isObject()) { |
| 152 | throw std::runtime_error("Batch member must be an object"); |
| 153 | } |
| 154 | size_t id = rec["id"].getInt<int>(); |
| 155 | if (id >= num) { |
| 156 | throw std::runtime_error( |
| 157 | "Batch member id is larger than batch size"); |
| 158 | } |
| 159 | batch[id] = rec; |
| 160 | } |
| 161 | return batch; |
| 162 | } |
| 163 | |
| 164 | void JSONRPCRequest::parse(const UniValue &valRequest) { |
| 165 | // Parse request |
no test coverage detected