Don't allow handlers::poll() to return None (#811)

This commit is contained in:
Pierre Krieger
2019-01-02 14:22:23 +01:00
committed by GitHub
parent f903e2b744
commit 2c2fc8bfd3
14 changed files with 97 additions and 82 deletions

View File

@ -97,23 +97,21 @@ where
fn poll(
&mut self,
) -> Poll<
Option<
ProtocolsHandlerEvent<
Self::OutboundProtocol,
Self::OutboundOpenInfo,
Self::OutEvent,
>,
ProtocolsHandlerEvent<
Self::OutboundProtocol,
Self::OutboundOpenInfo,
Self::OutEvent,
>,
Self::Error,
> {
if !self.pending_result.is_empty() {
return Ok(Async::Ready(Some(ProtocolsHandlerEvent::Custom(
return Ok(Async::Ready(ProtocolsHandlerEvent::Custom(
self.pending_result.remove(0),
))));
)));
}
if self.shutdown {
Ok(Async::Ready(None))
Ok(Async::Ready(ProtocolsHandlerEvent::Shutdown))
} else {
Ok(Async::NotReady)
}

View File

@ -126,24 +126,22 @@ where
fn poll(
&mut self,
) -> Poll<
Option<
ProtocolsHandlerEvent<
Self::OutboundProtocol,
Self::OutboundOpenInfo,
PeriodicIdHandlerEvent,
>,
ProtocolsHandlerEvent<
Self::OutboundProtocol,
Self::OutboundOpenInfo,
PeriodicIdHandlerEvent,
>,
Self::Error,
> {
if let Some(pending_result) = self.pending_result.take() {
return Ok(Async::Ready(Some(ProtocolsHandlerEvent::Custom(
return Ok(Async::Ready(ProtocolsHandlerEvent::Custom(
pending_result,
))));
)));
}
let next_id = match self.next_id {
Some(ref mut nid) => nid,
None => return Ok(Async::Ready(None)),
None => return Ok(Async::Ready(ProtocolsHandlerEvent::Shutdown)),
};
// Poll the future that fires when we need to identify the node again.
@ -153,7 +151,7 @@ where
next_id.reset(Instant::now() + DELAY_TO_NEXT_ID);
let upgrade = self.config.clone();
let ev = ProtocolsHandlerEvent::OutboundSubstreamRequest { upgrade, info: () };
Ok(Async::Ready(Some(ev)))
Ok(Async::Ready(ev))
}
}
}