Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/protocol.cpp
Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | |||||
void DeleteAuthCookie() { | 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__, e.what()); | __func__, e.what()); | ||||
} | } | ||||
} | } | ||||
std::vector<UniValue> JSONRPCProcessBatchReply(const UniValue &in, size_t num) { | |||||
if (!in.isArray()) { | |||||
throw std::runtime_error("Batch must be an array"); | |||||
} | |||||
std::vector<UniValue> batch(num); | |||||
for (size_t i = 0; i < in.size(); ++i) { | |||||
const UniValue &rec = in[i]; | |||||
if (!rec.isObject()) { | |||||
throw std::runtime_error("Batch member must be object"); | |||||
} | |||||
size_t id = rec["id"].get_int(); | |||||
if (id >= num) { | |||||
throw std::runtime_error("Batch member id larger than size"); | |||||
} | |||||
batch[id] = rec; | |||||
} | |||||
return batch; | |||||
} |