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

fix(client): support batched notifications #1327

Merged
merged 1 commit into from Mar 22, 2024

Conversation

lavigneer
Copy link
Contributor

As per the examples in the jsonrpc specification, it is valid to include only notifications in a batch.

rpc call Batch (all notifications):

--> [
        {"jsonrpc": "2.0", "method": "notify_sum", "params": [1,2,4]},
        {"jsonrpc": "2.0", "method": "notify_hello", "params": [7]}
    ]
<-- //Nothing is returned for all notification batches

This change adds support for handling this use case.

I ran into this while trying to leverage this library for a proof of conept I was working on a little while back,. My particular use case was using the client crate of this library to communicate with an existing service. I realized I never upstreamed this change and figured it might be useful to others.

I didn't see any contribution guidelines for this project, so please let me know if I'm missing any information. If you're not accepting external contributions I understand and can close this out. Thanks for your time.

@lavigneer lavigneer requested a review from a team as a code owner March 21, 2024 01:19
format!(r#"[{{"jsonrpc":"2.0","method":"{}", "params":{} }}]"#, method, serde_json::to_string(&params).unwrap())
}


Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

Copy link
Member

@niklasad1 niklasad1 left a comment

Choose a reason for hiding this comment

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

Thanks, looks good

EDIT: just run cargo +stable fmt --all on your code to make the CI happy

@lavigneer
Copy link
Contributor Author

Thanks, looks good

EDIT: just run cargo +stable fmt --all on your code to make the CI happy

Done and pushed. Thanks

@niklasad1 niklasad1 merged commit 0d89c1a into paritytech:master Mar 22, 2024
7 of 10 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants