-
Notifications
You must be signed in to change notification settings - Fork 696
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
archive: Refactor archive_storage
method into subscription
#6483
base: lexnv/storage-diff
Are you sure you want to change the base?
Conversation
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
instead Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
|
||
/// Sends all the events to the sink. | ||
async fn process_storage_events(rx: &mut mpsc::Receiver<QueryResult>, sink: &mut Subscription) { | ||
while let Some(event) = rx.recv().await { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps do a select loop here instead to terminate this when the subscription is closed, just to be on the safe side if the connection gets idle after getting being backpressured and no events are emitted....
loop {
tokio::select! {
_ = sink.closed() => return,
event = rx.recv() => { // code to read the event here }
}
}
@@ -57,42 +59,12 @@ use tokio::sync::mpsc; | |||
|
|||
pub(crate) const LOG_TARGET: &str = "rpc-spec-v2::archive"; | |||
|
|||
/// The configuration of [`Archive`]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woo 🥇
This PR adapts the
archive_storage
implementation from a method to a subscription.This keeps the archive APIs uniform and consistent.
Builds on: #5997
cc @paritytech/subxt-team