| 133 | } |
| 134 | |
| 135 | std::vector<UniValue> JSONRPCProcessBatchReply(const UniValue &in, size_t num) |
| 136 | { |
| 137 | if (!in.isArray()) { |
| 138 | throw std::runtime_error("Batch must be an array"); |
| 139 | } |
| 140 | std::vector<UniValue> batch(num); |
| 141 | for (size_t i=0; i<in.size(); ++i) { |
| 142 | const UniValue &rec = in[i]; |
| 143 | if (!rec.isObject()) { |
| 144 | throw std::runtime_error("Batch member must be object"); |
| 145 | } |
| 146 | size_t id = rec["id"].get_int(); |
| 147 | if (id >= num) { |
| 148 | throw std::runtime_error("Batch member id larger than size"); |
| 149 | } |
| 150 | batch[id] = rec; |
| 151 | } |
| 152 | return batch; |
| 153 | } |
no test coverage detected