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

client/finality-grandpa/src/observer: Poll NetworkBridge #4766

Merged
merged 1 commit into from
Jan 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions client/finality-grandpa/src/observer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,8 @@ where
{
type Output = Result<(), Error>;

fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
let this = Pin::into_inner(self);

match Future::poll(Pin::new(&mut this.observer), cx) {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
match Future::poll(Pin::new(&mut self.observer), cx) {
Poll::Pending => {}
Poll::Ready(Ok(())) => {
// observer commit stream doesn't conclude naturally; this could reasonably be an error.
Expand All @@ -351,24 +349,24 @@ where
}
Poll::Ready(Err(CommandOrError::VoterCommand(command))) => {
// some command issued internally
this.handle_voter_command(command)?;
self.handle_voter_command(command)?;
cx.waker().wake_by_ref();
}
}

match Stream::poll_next(Pin::new(&mut this.voter_commands_rx), cx) {
match Stream::poll_next(Pin::new(&mut self.voter_commands_rx), cx) {
Poll::Pending => {}
Poll::Ready(None) => {
// the `voter_commands_rx` stream should never conclude since it's never closed.
return Poll::Ready(Ok(()))
}
Poll::Ready(Some(command)) => {
// some command issued externally
this.handle_voter_command(command)?;
self.handle_voter_command(command)?;
cx.waker().wake_by_ref();
}
}

Poll::Pending
Future::poll(Pin::new(&mut self.network), cx)
}
}