-
Notifications
You must be signed in to change notification settings - Fork 122
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
Move sleep-time from node argument to rpc argument #1826
Conversation
@@ -596,7 +596,8 @@ UniValue votegovbatch(const JSONRPCRequest &request) { | |||
{"masternodeId", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "The masternode ID, operator or owner address"}, | |||
{"decision", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "The vote decision (yes/no/neutral)"}, | |||
}}, | |||
}, | |||
{"sleepTime", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "Sets sleeping time for voteGovBatch, by default the value is set to 500ms"} |
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.
Formatting looks off
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.
Thought the same at a glance but look okay in the file imo.
ain/src/masternodes/rpc_proposals.cpp
Line 599 in 9fcb98c
{"sleepTime", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "Sets sleeping time for voteGovBatch, by default the value is set to 500ms"} |
src/masternodes/rpc_proposals.cpp
Outdated
@@ -611,7 +612,7 @@ UniValue votegovbatch(const JSONRPCRequest &request) { | |||
RPCTypeCheck(request.params, {UniValue::VARR}, false); | |||
|
|||
const auto &keys = request.params[0].get_array(); | |||
auto sleepTime = gArgs.GetBoolArg("-sleep-time", SLEEP_TIME_MILLIS); | |||
auto sleepTime = request.params[1].isNull() ? SLEEP_TIME_MILLIS : request.params[1].get_int(); |
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 think you need to check if the param is set first, otherwise the node may crash.
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.
.isNull() is the check.
@@ -612,7 +613,7 @@ UniValue votegovbatch(const JSONRPCRequest &request) { | |||
RPCTypeCheck(request.params, {UniValue::VARR}, false); | |||
|
|||
const auto &keys = request.params[0].get_array(); | |||
auto sleepTime = request.params[1].isNull() ? SLEEP_TIME_MILLIS : request.params[1].get_int(); | |||
auto sleepTime = (request.params.size() > 1 && request.params[1].isNull()) ? SLEEP_TIME_MILLIS : request.params[1].get_int(); |
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.
You can leave this as it but isNull() is safe to call without a size() check as UniValue defines [] usage and makes it safe to use on non-existent entries. Check other isNull() usage in the code on optional RPC arguments.
Previously added a sleep_time node parameter for votegovbatch. Moved it as an RPC parameter instead of node parameter.