-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Remove wait on future in network bridge #1765
Conversation
3d70624
to
33c932f
Compare
core/finality-grandpa/src/lib.rs
Outdated
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> { | ||
if let Some(ref mut inner) = self.inner { | ||
return inner | ||
.poll() |
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.
Weird line break.
core/finality-grandpa/src/lib.rs
Outdated
return inner | ||
.poll() | ||
} | ||
if let Ok(futures::Async::Ready(mut inner)) = self.outer.poll() { |
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.
If the oneshot::Receiver
is returning Error(Canceled)
, this will stuck forever.
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.
How could we handle the error? An error would indicate network has shut down, and the entire system is likely shutting down. We could panic on an Err
I guess...
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.
I don't know what the error indicates. Maybe we should just throw Err(())
.
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.
We can propagate an appropriate error.
core/finality-grandpa/src/lib.rs
Outdated
self.inner = Some(inner); | ||
return poll_result | ||
} | ||
Ok(futures::Async::NotReady) |
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.
Maybe rewrite this whole function as:
loop {
match self.inner {
Some(ref mut inner) => return inner.poll(),
None => match self.outer.poll() {
Ok(Ready(inner)) => self.inner = Some(inner),
Ok(NotReady) => return Ok(NotReady),
Err(e) => handle the error,
}
}
}
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.
clever, and I'd rather rely on the next call to poll
(or actually just do it in the same call to poll
without the loop).
4a18ff3
to
f8c8dd4
Compare
* remove wait on future in network bridge * nit Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com> * nit Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com> * nit * propagate error * nit once more * nit Co-Authored-By: gterzian <2792687+gterzian@users.noreply.github.com>
Follow up on #1340 (comment)