diff --git a/protocols/request-response/CHANGELOG.md b/protocols/request-response/CHANGELOG.md index 613e7f6eab87..9638538f5de2 100644 --- a/protocols/request-response/CHANGELOG.md +++ b/protocols/request-response/CHANGELOG.md @@ -1,5 +1,7 @@ # 0.24.0 [unreleased] +- Update to the `libp2p_swarm::handler::ConnectionEvent` `DialTimeout` introduction and consequential changes. See [PR XXXX]. + - Update to `libp2p-core` `v0.39.0`. - Rename types as per [discussion 2174]. @@ -13,6 +15,7 @@ [discussion 2174]: https://github.com/libp2p/rust-libp2p/discussions/2174 [PR 3159]: https://github.com/libp2p/rust-libp2p/pull/3159 +[PR XXXX]: https://github.com/libp2p/rust-libp2p/pull/XXXX # 0.23.0 diff --git a/protocols/request-response/src/handler.rs b/protocols/request-response/src/handler.rs index 50cd6adb0556..da87424a7d88 100644 --- a/protocols/request-response/src/handler.rs +++ b/protocols/request-response/src/handler.rs @@ -24,8 +24,8 @@ use crate::codec::Codec; use crate::{RequestId, EMPTY_QUEUE_SHRINK_THRESHOLD}; use libp2p_swarm::handler::{ - ConnectionEvent, DialUpgradeError, FullyNegotiatedInbound, FullyNegotiatedOutbound, - ListenUpgradeError, + ConnectionEvent, DialTimeout, DialUpgradeError, FullyNegotiatedInbound, + FullyNegotiatedOutbound, ListenUpgradeError, }; pub use protocol::{ProtocolSupport, RequestProtocol, ResponseProtocol}; @@ -33,7 +33,7 @@ use futures::{channel::oneshot, future::BoxFuture, prelude::*, stream::FuturesUn use instant::Instant; use libp2p_core::upgrade::{NegotiationError, UpgradeError}; use libp2p_swarm::{ - handler::{ConnectionHandler, ConnectionHandlerEvent, ConnectionHandlerUpgrErr, KeepAlive}, + handler::{ConnectionHandler, ConnectionHandlerEvent, KeepAlive}, SubstreamProtocol, }; use smallvec::SmallVec; @@ -72,7 +72,7 @@ where /// The current connection keep-alive. keep_alive: KeepAlive, /// A pending fatal error that results in the connection being closed. - pending_error: Option>, + pending_error: Option>, /// Queue of events to emit in `poll()`. pending_events: VecDeque>, /// Outbound upgrades waiting to be emitted as an `OutboundSubstreamRequest`. @@ -145,10 +145,7 @@ where >, ) { match error { - ConnectionHandlerUpgrErr::Timeout => { - self.pending_events.push_back(Event::OutboundTimeout(info)); - } - ConnectionHandlerUpgrErr::Upgrade(UpgradeError::Select(NegotiationError::Failed)) => { + UpgradeError::Select(NegotiationError::Failed) => { // The remote merely doesn't support the protocol(s) we requested. // This is no reason to close the connection, which may // successfully communicate with other protocols already. @@ -172,10 +169,7 @@ where >, ) { match error { - ConnectionHandlerUpgrErr::Timeout => { - self.pending_events.push_back(Event::InboundTimeout(info)) - } - ConnectionHandlerUpgrErr::Upgrade(UpgradeError::Select(NegotiationError::Failed)) => { + UpgradeError::Select(NegotiationError::Failed) => { // The local peer merely doesn't support the protocol(s) requested. // This is no reason to close the connection, which may // successfully communicate with other protocols already. @@ -284,7 +278,7 @@ where { type InEvent = RequestProtocol; type OutEvent = Event; - type Error = ConnectionHandlerUpgrErr; + type Error = UpgradeError; type InboundProtocol = ResponseProtocol; type OutboundProtocol = RequestProtocol; type OutboundOpenInfo = RequestId; @@ -419,6 +413,9 @@ where response, }); } + ConnectionEvent::DialTimeout(DialTimeout { info }) => { + self.pending_events.push_back(Event::OutboundTimeout(info)) + } ConnectionEvent::DialUpgradeError(dial_upgrade_error) => { self.on_dial_upgrade_error(dial_upgrade_error) }