mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-27 16:51:34 +00:00
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:
@ -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)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user