File tree Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -251,7 +251,7 @@ class GetinfoRequestHandler: public BaseRequestHandler
251
251
UniValue ProcessReply (const UniValue &batch_in) override
252
252
{
253
253
UniValue result (UniValue::VOBJ);
254
- std::vector<UniValue> batch = JSONRPCProcessBatchReply (batch_in, batch_in. size () );
254
+ const std::vector<UniValue> batch = JSONRPCProcessBatchReply (batch_in);
255
255
// Errors in getnetworkinfo() and getblockchaininfo() are fatal, pass them on;
256
256
// getwalletinfo() and getbalances() are allowed to fail if there is no wallet.
257
257
if (!batch[ID_NETWORKINFO][" error" ].isNull ()) {
Original file line number Diff line number Diff line change @@ -130,20 +130,20 @@ void DeleteAuthCookie()
130
130
}
131
131
}
132
132
133
- std::vector<UniValue> JSONRPCProcessBatchReply (const UniValue &in, size_t num )
133
+ std::vector<UniValue> JSONRPCProcessBatchReply (const UniValue& in )
134
134
{
135
135
if (!in.isArray ()) {
136
136
throw std::runtime_error (" Batch must be an array" );
137
137
}
138
+ const size_t num {in.size ()};
138
139
std::vector<UniValue> batch (num);
139
- for (size_t i=0 ; i<in.size (); ++i) {
140
- const UniValue &rec = in[i];
140
+ for (const UniValue& rec : in.getValues ()) {
141
141
if (!rec.isObject ()) {
142
- throw std::runtime_error (" Batch member must be object" );
142
+ throw std::runtime_error (" Batch member must be an object" );
143
143
}
144
144
size_t id = rec[" id" ].get_int ();
145
145
if (id >= num) {
146
- throw std::runtime_error (" Batch member id larger than size" );
146
+ throw std::runtime_error (" Batch member id is larger than batch size" );
147
147
}
148
148
batch[id] = rec;
149
149
}
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ bool GetAuthCookie(std::string *cookie_out);
22
22
/* * Delete RPC authentication cookie from disk */
23
23
void DeleteAuthCookie ();
24
24
/* * Parse JSON-RPC batch reply into a vector */
25
- std::vector<UniValue> JSONRPCProcessBatchReply (const UniValue &in, size_t num );
25
+ std::vector<UniValue> JSONRPCProcessBatchReply (const UniValue& in );
26
26
27
27
class JSONRPCRequest
28
28
{
You can’t perform that action at this time.
0 commit comments