-
Notifications
You must be signed in to change notification settings - Fork 37.7k
rpc: Actually throw help when passed invalid number of params #15401
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
Conversation
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.
Tested with master binary and functional test fails.
fa910b0
to
fa4ce70
Compare
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.
Tested ACK fa4ce70.
Could update license year in test/functional/rpc_getblockstats.py.
break; | ||
} | ||
} | ||
return num_required_args <= num_args && num_args <= m_args.size(); |
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.
nit, could early return with if (num_args > m_args.size()) return false;
.
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 this is the wrong place to overoptimize
bool RPCHelpMan::IsValidNumArgs(size_t num_args) const | ||
{ | ||
size_t num_required_args = 0; | ||
for (size_t n = m_args.size(); n > 0; --n) { |
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.
nit, could change condition to n > num_args
?
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.
No, that would be incorrect
Please, let's not start nitting about copyright years. In as far as they matter at all (we don't know!) updating these once per year is enough. |
utACK fa4ce70 |
…params fa4ce70 rpc: Actually throw help when passed invalid number of params (MarcoFalke) fa05626 rpc: Add RPCHelpMan::IsValidNumArgs() (MarcoFalke) Pull request description: Can be tested by * running the included test against an old binary (compiled without this patch) * calling `setban 1 "add" 3 4 5 6 7 8 9 0` in the gui Tree-SHA512: aa6a25bbe6f40722913ea292252a62a4012c964eed9f4035335a2e2d13be98eb60f368e8a3251a104a26a62c08b2cb926b06e5ab1418ef1cf4abdd71d87c2919
Summary: * rpc: Add RPCHelpMan::IsValidNumArgs() This is a backport of Core [[bitcoin/bitcoin#15401 | PR15401]] Depends on D6064 Test Plan: ninja all check-all Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: majcosta Differential Revision: https://reviews.bitcoinabc.org/D6220
Can be tested by
setban 1 "add" 3 4 5 6 7 8 9 0
in the gui