Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Feb 13, 2019

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

@maflcko maflcko added this to the 0.18.0 milestone Feb 18, 2019
Copy link
Contributor

@promag promag left a 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.

Copy link
Contributor

@promag promag left a 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();
Copy link
Contributor

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;.

Copy link
Member Author

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) {
Copy link
Contributor

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?

Copy link
Member Author

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

@laanwj
Copy link
Member

laanwj commented Feb 25, 2019

Could update license year in test/functional/rpc_getblockstats.py.

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.

@laanwj
Copy link
Member

laanwj commented Feb 25, 2019

utACK fa4ce70

@laanwj laanwj merged commit fa4ce70 into bitcoin:master Feb 25, 2019
laanwj added a commit that referenced this pull request Feb 25, 2019
…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
@maflcko maflcko deleted the Mf1902-rpcNumArgs branch February 25, 2019 14:48
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 22, 2020
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
kwvg added a commit to kwvg/dash that referenced this pull request Dec 12, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Dec 12, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants