-
Notifications
You must be signed in to change notification settings - Fork 718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RPC] Cleanup startmasternode command #2833
[RPC] Cleanup startmasternode command #2833
Conversation
- Remove 'local' set support. Long-time NonOp. - Remove 'many' set support. Always NonOp. - General cleanup of the command's logic.
Adds a method to start multiple MNs with a single command, adding code coverage to the more 'heavy-lifter' portion of the startmasternode command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK 815bbc2
Working as intended, no more confusion in starting master nodes with these commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good apart one small change request
if (request.fHelp || request.params.size() < 2 || request.params.size() > 4 || | ||
(request.params.size() == 2 && (strCommand != "local" && strCommand != "all" && strCommand != "many" && strCommand != "missing" && strCommand != "disabled")) || | ||
( (request.params.size() == 3 || request.params.size() == 4) && strCommand != "alias")) | ||
(strCommand == "alias" && request.params.size() < 3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve this if:
if the strCommand is "alias" you must use either 3 or 4 params
if the strCommand is valid but not "alias" you must use 2 params
if the strCommand is not valid you should throw error anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the strCommand is "alias" you must use either 3 or 4 params
"alias" requires at least 3 arguments, this is specifically covered in this conditional check.
if the strCommand is valid but not "alias" you must use 2 params
This is no longer the case, as shown in the changes to the functional tests that use named arguments with the "all" command whilst reloading the masternode.conf
file (here and here).
if the strCommand is not valid you should throw error anyways
This does that, and is tested in the functional tests (here) by returning a RPC_INVALID_PARAMETER
error code. This is done towards the end of the RPC function call and not at the beginning intentionally (here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the strCommand is not valid you should throw error anyways
This does that, and is tested in the functional tests (here) by returning a
RPC_INVALID_PARAMETER
error code. This is done towards the end of the RPC function call and not at the beginning intentionally (here).
Yep I saw that my main point was that (as a user) I would prefer that if I inserted an invalid strCommand the output would be error + how to use that rpc command (as it was done before) instead of a simple "Invalid strCommand" and same for the number of parameters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved to this approach for a few reasons:
- It allows greater code coverage and testability.
- A user's natural instinct upon getting an
RPC_INVALID_PARAMETER
error (SHOULD) be to then check thehelp
output. - This new behavior is much much more inline with the rest of our RPC commands, and greatly simplifies the logic checks being done for when to show the actual help output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok still don't totally agree but I'm not blocking the PR for this small thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK 815bbc2
General cleanup of the
startmasternode
RPC command. This has been a long time coming, and rectifies some long-standing issues with the design and operability of the command.Adds code coverage for new failure cases as well as code coverage for multi-MN start (ie, not "alias"-only) start commands.