Add ProtocolsHandler::InboundOpenInfo. (#1714)

* Add `ProtocolsHandler::InboundOpenInfo`.

* Update swarm/src/protocols_handler/multi.rs

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>

* Update CHANGELOGs and versions.

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
This commit is contained in:
Toralf Wittner
2020-08-23 16:57:20 +02:00
committed by GitHub
parent 740a2e0235
commit 0b05b21093
32 changed files with 337 additions and 204 deletions

View File

@ -145,8 +145,9 @@ where
type InboundProtocol = ResponseProtocol<TCodec>;
type OutboundProtocol = RequestProtocol<TCodec>;
type OutboundOpenInfo = RequestId;
type InboundOpenInfo = ();
fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol> {
fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol, Self::InboundOpenInfo> {
// A channel for notifying the handler when the inbound
// upgrade received the request.
let (rq_send, rq_recv) = oneshot::channel();
@ -173,12 +174,13 @@ where
// `ResponseChannel`.
self.inbound.push(rq_recv.map_ok(move |rq| (rq, rs_send)).boxed());
SubstreamProtocol::new(proto).with_timeout(self.substream_timeout)
SubstreamProtocol::new(proto, ()).with_timeout(self.substream_timeout)
}
fn inject_fully_negotiated_inbound(
&mut self,
(): (),
(): ()
) {
// Nothing to do, as the response has already been sent
// as part of the upgrade.
@ -229,6 +231,7 @@ where
fn inject_listen_upgrade_error(
&mut self,
(): Self::InboundOpenInfo,
error: ProtocolsHandlerUpgrErr<io::Error>
) {
match error {
@ -300,9 +303,8 @@ where
let info = request.request_id;
return Poll::Ready(
ProtocolsHandlerEvent::OutboundSubstreamRequest {
protocol: SubstreamProtocol::new(request)
.with_timeout(self.substream_timeout),
info,
protocol: SubstreamProtocol::new(request, info)
.with_timeout(self.substream_timeout)
},
)
}