From 903b6c117f541ea9258d3234ffcf59427344e668 Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Sun, 12 Apr 2020 21:46:16 +0200 Subject: [PATCH] rpc: drop unused JSONRPCProcessBatchReply size arg, refactor --- src/bitcoin-cli.cpp | 2 +- src/rpc/request.cpp | 10 +++++----- src/rpc/request.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 045442c9ff3..45a586cd120 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -251,7 +251,7 @@ public: UniValue ProcessReply(const UniValue &batch_in) override { UniValue result(UniValue::VOBJ); - std::vector batch = JSONRPCProcessBatchReply(batch_in, batch_in.size()); + const std::vector batch = JSONRPCProcessBatchReply(batch_in); // Errors in getnetworkinfo() and getblockchaininfo() are fatal, pass them on; // getwalletinfo() and getbalances() are allowed to fail if there is no wallet. if (!batch[ID_NETWORKINFO]["error"].isNull()) { diff --git a/src/rpc/request.cpp b/src/rpc/request.cpp index 56cac6661ec..7fef45f50ef 100644 --- a/src/rpc/request.cpp +++ b/src/rpc/request.cpp @@ -130,20 +130,20 @@ void DeleteAuthCookie() } } -std::vector JSONRPCProcessBatchReply(const UniValue &in, size_t num) +std::vector JSONRPCProcessBatchReply(const UniValue& in) { if (!in.isArray()) { throw std::runtime_error("Batch must be an array"); } + const size_t num {in.size()}; std::vector batch(num); - for (size_t i=0; i= 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; } diff --git a/src/rpc/request.h b/src/rpc/request.h index 99eb4f9354a..d6080c3cf30 100644 --- a/src/rpc/request.h +++ b/src/rpc/request.h @@ -22,7 +22,7 @@ bool GetAuthCookie(std::string *cookie_out); /** Delete RPC authentication cookie from disk */ void DeleteAuthCookie(); /** Parse JSON-RPC batch reply into a vector */ -std::vector JSONRPCProcessBatchReply(const UniValue &in, size_t num); +std::vector JSONRPCProcessBatchReply(const UniValue& in); class JSONRPCRequest {