Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/request.cpp
Show First 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | void DeleteAuthCookie() { | ||||
try { | try { | ||||
fs::remove(GetAuthCookieFile()); | fs::remove(GetAuthCookieFile()); | ||||
} catch (const fs::filesystem_error &e) { | } catch (const fs::filesystem_error &e) { | ||||
LogPrintf("%s: Unable to remove random auth cookie file: %s\n", | LogPrintf("%s: Unable to remove random auth cookie file: %s\n", | ||||
__func__, fsbridge::get_filesystem_error_message(e)); | __func__, fsbridge::get_filesystem_error_message(e)); | ||||
} | } | ||||
} | } | ||||
std::vector<UniValue> JSONRPCProcessBatchReply(const UniValue &in, size_t num) { | std::vector<UniValue> JSONRPCProcessBatchReply(const UniValue &in) { | ||||
if (!in.isArray()) { | if (!in.isArray()) { | ||||
throw std::runtime_error("Batch must be an array"); | throw std::runtime_error("Batch must be an array"); | ||||
} | } | ||||
const size_t num{in.size()}; | |||||
std::vector<UniValue> batch(num); | std::vector<UniValue> batch(num); | ||||
for (size_t i = 0; i < in.size(); ++i) { | for (const UniValue &rec : in.getValues()) { | ||||
const UniValue &rec = in[i]; | |||||
if (!rec.isObject()) { | if (!rec.isObject()) { | ||||
throw std::runtime_error("Batch member must be object"); | throw std::runtime_error("Batch member must be an object"); | ||||
} | } | ||||
size_t id = rec["id"].get_int(); | size_t id = rec["id"].get_int(); | ||||
if (id >= num) { | if (id >= num) { | ||||
throw std::runtime_error("Batch member id larger than size"); | throw std::runtime_error( | ||||
"Batch member id is larger than batch size"); | |||||
} | } | ||||
batch[id] = rec; | batch[id] = rec; | ||||
} | } | ||||
return batch; | return batch; | ||||
} | } | ||||
void JSONRPCRequest::parse(const UniValue &valRequest) { | void JSONRPCRequest::parse(const UniValue &valRequest) { | ||||
// Parse request | // Parse request | ||||
Show All 37 Lines |