Skip to content

Conversation

luke-jr
Copy link
Member

@luke-jr luke-jr commented Nov 2, 2019

Reworked #11660 to add a new m_params to JSONRPCRequest in parallel to the legacy params to ease the transition.

Dropped other unnecessary improvements and "options" handling for now to keep this PR smaller, those can go in later in other PRs.

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.

Concept ACK. Should mention in developer notes that named params is preferable for new code.

@luke-jr
Copy link
Member Author

luke-jr commented Nov 4, 2019

Well, my hope is that after this is merged, we can migrate existing code to use it and drop params entirely...

@luke-jr
Copy link
Member Author

luke-jr commented Nov 4, 2019

The echo method (rpc/misc) wants up to 100 args, but only names 10 of them. Should I teach the positional-to-named-args conversion to make ad-hoc argN as needed (currently in branch as a fixup), extend the named arg list out to 100, or reduce the number allowed by echo?

@maflcko
Copy link
Member

maflcko commented Nov 4, 2019

100 args are only needed to throw an internal bug report. You can replace that with a check that checks if the first argument is the string "throw_internal_bug_report" (or anything else you can come up with)

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 4, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@luke-jr luke-jr force-pushed the internal_named_params branch 2 times, most recently from 8186d29 to e52fa66 Compare March 17, 2020 16:40
@sipa
Copy link
Member

sipa commented Mar 17, 2020

Concept ACK

@luke-jr
Copy link
Member Author

luke-jr commented Mar 18, 2020

Alternative fix for rpc_misc pushed after a revert of the "fixup" version

@luke-jr luke-jr force-pushed the internal_named_params branch 2 times, most recently from 2735696 to f47bd98 Compare August 20, 2020 18:32
@luke-jr
Copy link
Member Author

luke-jr commented Aug 20, 2020

Rebased. Thanks to changes in master, neither hack is needed anymore.

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@luke-jr
Copy link
Member Author

luke-jr commented Jul 6, 2021

Doesn't seem to be much point in rebasing this. It'd be nice to have, but without any review interest, just wasting time.

@jonatack
Copy link
Member

Concept ACK

Copy link

@yanmaani yanmaani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK. This would make a lot of code much cleaner!

static inline JSONRPCRequest transformArguments(const JSONRPCRequest& in, const std::vector<std::string>& argNames)
{
auto out = in;
if (in.params.isObject()) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: wouldn't it be slightly cleaner to do something like:

bool isPositional = in.params.isObject();
out.m_used_positional_args = isPositional;
if (isPositional) { ... }

Same loc count, but reads slightly cleaner IMHO.

out.params = transformNamedArguments(in.params, argNames);
} else {
out.m_used_positional_args = true;
if (in.params.size() > argNames.size()) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some reason to do this after setting out.m_used_positional_args? Otherwise it seems either cleaner to put it first, or to put it last and take out the return out;.

@bitcoin bitcoin locked and limited conversation to collaborators Oct 30, 2022
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.

8 participants