aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/request.cpp
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2020-04-12 21:46:16 +0200
committerJon Atack <jon@atack.com>2020-05-21 10:24:26 +0200
commit903b6c117f541ea9258d3234ffcf59427344e668 (patch)
tree5b311e452098512acc1d413c65d9aef8516ddfbc /src/rpc/request.cpp
parentafce85eb994384246e455b766549c3206cb059e0 (diff)
downloadbitcoin-903b6c117f541ea9258d3234ffcf59427344e668.tar.xz
rpc: drop unused JSONRPCProcessBatchReply size arg, refactor
Diffstat (limited to 'src/rpc/request.cpp')
-rw-r--r--src/rpc/request.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/rpc/request.cpp b/src/rpc/request.cpp
index 56cac6661e..7fef45f50e 100644
--- a/src/rpc/request.cpp
+++ b/src/rpc/request.cpp
@@ -130,20 +130,20 @@ void DeleteAuthCookie()
}
}
-std::vector<UniValue> JSONRPCProcessBatchReply(const UniValue &in, size_t num)
+std::vector<UniValue> JSONRPCProcessBatchReply(const UniValue& in)
{
if (!in.isArray()) {
throw std::runtime_error("Batch must be an array");
}
+ const size_t num {in.size()};
std::vector<UniValue> batch(num);
- for (size_t i=0; i<in.size(); ++i) {
- const UniValue &rec = in[i];
+ for (const UniValue& rec : in.getValues()) {
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();
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;
}