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

rpc v2: submitAndWatch replace old messages if it's lagging #4901

Merged
merged 9 commits into from
Jul 29, 2024

Conversation

niklasad1
Copy link
Member

@niklasad1 niklasad1 commented Jun 27, 2024

Close #3076

The fix is really just that older messages are replaced if the client can't keep up with the server instead.
Because I wanted the same functionality as pipe_from_stream for both pending/subscription I added two wrapper types on-top of the types from jsonrpsee to make it nicer.

I added a trait Buffer so I could still use pipe_from_stream but that abstraction is a little leaky but only to avoid adding an identical method/function with another strategy...

stream.filter_map(move |event| async move { handle_event(event) }).boxed();

// If the subscription is too slow older events will be overwritten.
sink.pipe_from_stream(stream.boxed(), RingBuffer::new(3)).await;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the fix....

@niklasad1 niklasad1 requested a review from lexnv June 27, 2024 17:30
@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: cargo-clippy
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6579613

.expect("Serialize infallible; qed")
/// Send a message on the subscription.
pub async fn send(&self, result: &impl Serialize) -> Result<(), DisconnectError> {
self.0.send(self.to_sub_message(result)).await
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! This makes the api easier to use!

Copy link
Contributor

@lexnv lexnv left a comment

Choose a reason for hiding this comment

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

LGTM! Nice job here 👍

@niklasad1 niklasad1 added R0-silent Changes should not be mentioned in any release notes T0-node This PR/Issue is related to the topic “node”. and removed R0-silent Changes should not be mentioned in any release notes T0-node This PR/Issue is related to the topic “node”. labels Jul 5, 2024
@niklasad1 niklasad1 added this pull request to the merge queue Jul 5, 2024
@niklasad1 niklasad1 removed this pull request from the merge queue due to a manual request Jul 5, 2024
@niklasad1 niklasad1 enabled auto-merge July 5, 2024 13:46
@niklasad1 niklasad1 added this pull request to the merge queue Jul 5, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 5, 2024
@niklasad1 niklasad1 added this pull request to the merge queue Jul 29, 2024
Merged via the queue into master with commit fc10887 Jul 29, 2024
159 of 161 checks passed
@niklasad1 niklasad1 deleted the na-fix-3076 branch July 29, 2024 13:10
TarekkMA pushed a commit to moonbeam-foundation/polkadot-sdk that referenced this pull request Aug 2, 2024
…tech#4901)

Close paritytech#3076

The fix is really just that older messages are replaced if the client
can't keep up with the server instead.
Because I wanted the same functionality as `pipe_from_stream` for both
pending/subscription I added two wrapper types on-top of the types from
jsonrpsee to make it nicer.

I added a trait `Buffer` so I could still use pipe_from_stream but that
abstraction is a little leaky but only to avoid adding an identical
method/function with another strategy...
driemworks added a commit to ideal-lab5/polkadot-sdk that referenced this pull request Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R0-silent Changes should not be mentioned in any release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RPC-Spec-V2]: transactionWatch_unstable_submitAndWatch shouldn't use pipe_from_stream
4 participants