mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
rpc: drop unused JSONRPCProcessBatchReply size arg, refactor
This commit is contained in:
parent
afce85eb99
commit
903b6c117f
3 changed files with 7 additions and 7 deletions
|
@ -251,7 +251,7 @@ public:
|
|||
UniValue ProcessReply(const UniValue &batch_in) override
|
||||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
std::vector<UniValue> batch = JSONRPCProcessBatchReply(batch_in, batch_in.size());
|
||||
const std::vector<UniValue> 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()) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<UniValue> JSONRPCProcessBatchReply(const UniValue &in, size_t num);
|
||||
std::vector<UniValue> JSONRPCProcessBatchReply(const UniValue& in);
|
||||
|
||||
class JSONRPCRequest
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue