Skip to content
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

core_rpc_server_command_parser order #1606

Open
jagerman opened this issue Oct 15, 2022 · 0 comments
Open

core_rpc_server_command_parser order #1606

jagerman opened this issue Oct 15, 2022 · 0 comments

Comments

@jagerman
Copy link
Member

jagerman commented Oct 15, 2022

RPC argument parsing (on dev) is currently doing things like this:

    get_values(in, "host", set_bans.request.host);
    get_values(in, "ip", set_bans.request.ip);
    get_values(in, "seconds", set_bans.request.seconds);
    get_values(in, "ban", set_bans.request.ban);

But this is broken because parsing has to happen in alphabetical order (because we support bt-encoded RPC, where we consume arguments, but arguments have to always be sorted).

Aside from the ordering, get_values is meant to take a list of all (or many) options at once, like this:

    get_values(in,
        "ban", set_bans.request.ban,
        "host", set_bans.request.host,
        "ip", set_bans.request.ip,
        "seconds", set_bans.request.seconds);

aside from being slightly cleaner syntax, this will also catch (at runtime) the out-of-order keys and raise an exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant