Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Last finalized block lookup not required anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
davxy committed Jan 18, 2022
1 parent 3e59449 commit dbbe45a
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions client/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,26 +152,7 @@ async fn build_network_future<
let starting_block = client.info().best_number;

// Stream of finalized blocks reported by the client.
let mut finality_notification_stream = {
let mut finality_notification_stream = client.finality_notification_stream().fuse();

// We tweak the `Stream` in order to merge together multiple items if they happen to be
// ready. This way, we only get the latest finalized block.
stream::poll_fn(move |cx| {
let mut last = None;
while let Poll::Ready(Some(item)) =
Pin::new(&mut finality_notification_stream).poll_next(cx)
{
last = Some(item);
}
if let Some(last) = last {
Poll::Ready(Some(last))
} else {
Poll::Pending
}
})
.fuse()
};
let mut finality_notification_stream = client.finality_notification_stream().fuse();

loop {
futures::select! {
Expand Down

0 comments on commit dbbe45a

Please sign in to comment.