Skip to content

Commit 69d1c25

Browse files
committed
[RPC] Give RPC commands more information about the RPC request
1 parent 23c32a9 commit 69d1c25

File tree

13 files changed

+558
-547
lines changed

13 files changed

+558
-547
lines changed

src/httprpc.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,22 @@ static bool HTTPReq_JSONRPC(HTTPRequest* req, const std::string &)
172172
return false;
173173
}
174174

175-
JSONRequest jreq;
175+
JSONRPCRequest jreq;
176176
try {
177177
// Parse request
178178
UniValue valRequest;
179179
if (!valRequest.read(req->ReadBody()))
180180
throw JSONRPCError(RPC_PARSE_ERROR, "Parse error");
181181

182+
// Set the URI
183+
jreq.URI = req->GetURI();
184+
182185
std::string strReply;
183186
// singleton request
184187
if (valRequest.isObject()) {
185188
jreq.parse(valRequest);
186189

187-
UniValue result = tableRPC.execute(jreq.strMethod, jreq.params);
190+
UniValue result = tableRPC.execute(jreq);
188191

189192
// Send reply
190193
strReply = JSONRPCReply(result, NullUniValue, jreq.id);

src/qt/rpcconsole.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ bool RPCConsole::RPCExecuteCommandLine(std::string &strResult, const std::string
246246
std::string strPrint;
247247
// Convert argument list to JSON objects in method-dependent way,
248248
// and pass it along with the method name to the dispatcher.
249-
lastResult = tableRPC.execute(stack.back()[0], RPCConvertValues(stack.back()[0], std::vector<std::string>(stack.back().begin() + 1, stack.back().end())));
249+
JSONRPCRequest req;
250+
req.params = RPCConvertValues(stack.back()[0], std::vector<std::string>(stack.back().begin() + 1, stack.back().end()));
251+
req.strMethod = stack.back()[0];
252+
lastResult = tableRPC.execute(req);
250253

251254
state = STATE_COMMAND_EXECUTED;
252255
curarg.clear();

src/rest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static bool rest_block_notxdetails(HTTPRequest* req, const std::string& strURIPa
274274
}
275275

276276
// A bit of a hack - dependency on a function defined in rpc/blockchain.cpp
277-
UniValue getblockchaininfo(const UniValue& params, bool fHelp);
277+
UniValue getblockchaininfo(const JSONRPCRequest& request);
278278

279279
static bool rest_chaininfo(HTTPRequest* req, const std::string& strURIPart)
280280
{
@@ -285,8 +285,8 @@ static bool rest_chaininfo(HTTPRequest* req, const std::string& strURIPart)
285285

286286
switch (rf) {
287287
case RF_JSON: {
288-
UniValue rpcParams(UniValue::VARR);
289-
UniValue chainInfoObject = getblockchaininfo(rpcParams, false);
288+
JSONRPCRequest jsonRequest;
289+
UniValue chainInfoObject = getblockchaininfo(jsonRequest);
290290
string strJSON = chainInfoObject.write() + "\n";
291291
req->WriteHeader("Content-Type", "application/json");
292292
req->WriteReply(HTTP_OK, strJSON);

0 commit comments

Comments
 (0)