Skip to content

Commit

Permalink
request-response: update to libp2p-swarm ListenUpgradeError
Browse files Browse the repository at this point in the history
and DialUpgradeError updates.
  • Loading branch information
jxs committed Jan 6, 2023
1 parent 4d0b1f5 commit 59cfbf5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
3 changes: 3 additions & 0 deletions protocols/request-response/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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].
Expand All @@ -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

Expand Down
23 changes: 10 additions & 13 deletions protocols/request-response/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ 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};

use futures::{channel::oneshot, future::BoxFuture, prelude::*, stream::FuturesUnordered};
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;
Expand Down Expand Up @@ -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<ConnectionHandlerUpgrErr<io::Error>>,
pending_error: Option<UpgradeError<io::Error>>,
/// Queue of events to emit in `poll()`.
pending_events: VecDeque<Event<TCodec>>,
/// Outbound upgrades waiting to be emitted as an `OutboundSubstreamRequest`.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -284,7 +278,7 @@ where
{
type InEvent = RequestProtocol<TCodec>;
type OutEvent = Event<TCodec>;
type Error = ConnectionHandlerUpgrErr<io::Error>;
type Error = UpgradeError<io::Error>;
type InboundProtocol = ResponseProtocol<TCodec>;
type OutboundProtocol = RequestProtocol<TCodec>;
type OutboundOpenInfo = RequestId;
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 59cfbf5

Please sign in to comment.