Skip to content

Commit fa19bb2

Browse files
author
MarcoFalke
committed
remove dead rpc code
Checking for fHelp, or the size of the args, is dead code because: * fHelp is always false (src/qt/test/rpcnestedtests.cpp) * It is already implicitly called by RPCHelpMan::Check (src/rpc/mining.cpp, src/rpc/misc.cpp, src/rpc/net.cpp)
1 parent 1b313ca commit fa19bb2

File tree

4 files changed

+3
-13
lines changed

4 files changed

+3
-13
lines changed

src/qt/test/rpcnestedtests.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
static UniValue rpcNestedTest_rpc(const JSONRPCRequest& request)
1818
{
19-
if (request.fHelp) {
20-
return "help message";
21-
}
2219
return request.params.write(0, 0);
2320
}
2421

src/rpc/mining.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,7 @@ static RPCHelpMan generatetodescriptor()
242242
static RPCHelpMan generate()
243243
{
244244
return RPCHelpMan{"generate", "has been replaced by the -generate cli option. Refer to -help for more information.", {}, {}, RPCExamples{""}, [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue {
245-
246-
if (request.fHelp) {
247-
throw std::runtime_error(self.ToString());
248-
} else {
249245
throw JSONRPCError(RPC_METHOD_NOT_FOUND, self.ToString());
250-
}
251246
}};
252247
}
253248

src/rpc/misc.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,6 @@ static RPCHelpMan echo(const std::string& name)
624624
RPCExamples{""},
625625
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
626626
{
627-
if (request.fHelp) throw std::runtime_error(self.ToString());
628-
629627
if (request.params[9].isStr()) {
630628
CHECK_NONFATAL(request.params[9].get_str() != "trigger_internal_bug");
631629
}

src/rpc/net.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,10 @@ static RPCHelpMan addnode()
262262
std::string strCommand;
263263
if (!request.params[1].isNull())
264264
strCommand = request.params[1].get_str();
265-
if (request.fHelp || request.params.size() != 2 ||
266-
(strCommand != "onetry" && strCommand != "add" && strCommand != "remove"))
265+
if (strCommand != "onetry" && strCommand != "add" && strCommand != "remove") {
267266
throw std::runtime_error(
268267
self.ToString());
268+
}
269269

270270
NodeContext& node = EnsureNodeContext(request.context);
271271
if(!node.connman)
@@ -604,7 +604,7 @@ static RPCHelpMan setban()
604604
std::string strCommand;
605605
if (!request.params[1].isNull())
606606
strCommand = request.params[1].get_str();
607-
if (request.fHelp || !help.IsValidNumArgs(request.params.size()) || (strCommand != "add" && strCommand != "remove")) {
607+
if (strCommand != "add" && strCommand != "remove") {
608608
throw std::runtime_error(help.ToString());
609609
}
610610
NodeContext& node = EnsureNodeContext(request.context);

0 commit comments

Comments
 (0)