@@ -297,35 +297,33 @@ static RPCHelpMan addnode()
297
297
},
298
298
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
299
299
{
300
- std::string strCommand;
301
- if (!request.params [1 ].isNull ())
302
- strCommand = request.params [1 ].get_str ();
303
- if (strCommand != " onetry" && strCommand != " add" && strCommand != " remove" ) {
300
+ const std::string command{request.params [1 ].get_str ()};
301
+ if (command != " onetry" && command != " add" && command != " remove" ) {
304
302
throw std::runtime_error (
305
303
self.ToString ());
306
304
}
307
305
308
306
NodeContext& node = EnsureAnyNodeContext (request.context );
309
307
CConnman& connman = EnsureConnman (node);
310
308
311
- std::string strNode = request.params [0 ].get_str ();
309
+ const std::string node_arg{ request.params [0 ].get_str ()} ;
312
310
313
- if (strCommand == " onetry" )
311
+ if (command == " onetry" )
314
312
{
315
313
CAddress addr;
316
- connman.OpenNetworkConnection (addr, false , nullptr , strNode .c_str (), ConnectionType::MANUAL);
314
+ connman.OpenNetworkConnection (addr, /* fCountFailure= */ false , /* grantOutbound= */ nullptr , node_arg .c_str (), ConnectionType::MANUAL);
317
315
return UniValue::VNULL;
318
316
}
319
317
320
- if (strCommand == " add" )
318
+ if (command == " add" )
321
319
{
322
- if (!connman.AddNode (strNode )) {
320
+ if (!connman.AddNode (node_arg )) {
323
321
throw JSONRPCError (RPC_CLIENT_NODE_ALREADY_ADDED, " Error: Node already added" );
324
322
}
325
323
}
326
- else if (strCommand == " remove" )
324
+ else if (command == " remove" )
327
325
{
328
- if (!connman.RemoveAddedNode (strNode )) {
326
+ if (!connman.RemoveAddedNode (node_arg )) {
329
327
throw JSONRPCError (RPC_CLIENT_NODE_NOT_ADDED, " Error: Node could not be removed. It has not been added previously." );
330
328
}
331
329
}
0 commit comments