Skip to content

Commit

Permalink
fix(swarm): un-deprecate ConnectionHandler::{In,Out}boundOpenInfo
Browse files Browse the repository at this point in the history
Closes #5858

Pull-Request: #5860.
  • Loading branch information
jxs authored Feb 15, 2025
1 parent a966f62 commit 34252f0
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ libp2p-rendezvous = { version = "0.16.0", path = "protocols/rendezvous" }
libp2p-request-response = { version = "0.28.1", path = "protocols/request-response" }
libp2p-server = { version = "0.12.6", path = "misc/server" }
libp2p-stream = { version = "0.3.0-alpha", path = "protocols/stream" }
libp2p-swarm = { version = "0.46.0", path = "swarm" }
libp2p-swarm = { version = "0.46.1", path = "swarm" }
libp2p-swarm-derive = { version = "=0.35.1", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required.
libp2p-swarm-test = { version = "0.5.0", path = "swarm-test" }
libp2p-tcp = { version = "0.43.0", path = "transports/tcp" }
Expand Down
14 changes: 10 additions & 4 deletions swarm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.46.1
- Undo `ConnectionHandler::{InboundOpenInfo, OutboundOpenInfo}` deprecation.
Substreams are not completely interchangeable and a certain Substream may be associated with a
certain upgrade.
See [PR 5860](https://github.com/libp2p/rust-libp2p/pull/5860).

## 0.46.0

- Don't report `NewExternalAddrCandidate` for confirmed external addresses.
Expand All @@ -12,11 +18,11 @@
- Update default for idle-connection-timeout to 10s.
See [PR 4967](https://github.com/libp2p/rust-libp2p/pull/4967).

- Deprecate `ConnectionHandler::{InboundOpenInfo, OutboundOpenInfo}` associated type.
Previously, users could tag pending sub streams with custom data and retrieve the data
- Deprecate `ConnectionHandler::{InboundOpenInfo, OutboundOpenInfo}` associated type.
Previously, users could tag pending sub streams with custom data and retrieve the data
after the substream has been negotiated.
But substreams themselves are completely interchangeable, users should instead track
additional data inside `ConnectionHandler` after negotiation.
But substreams themselves are completely interchangeable, users should instead track
additional data inside `ConnectionHandler` after negotiation.
See [PR 5242](https://github.com/libp2p/rust-libp2p/pull/5242).

<!-- Update to libp2p-core v0.43.0 -->
Expand Down
2 changes: 1 addition & 1 deletion swarm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-swarm"
edition = "2021"
rust-version = { workspace = true }
description = "The libp2p swarm"
version = "0.46.0"
version = "0.46.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
3 changes: 0 additions & 3 deletions swarm/src/behaviour/toggle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ impl<TInner> ToggleConnectionHandler<TInner>
where
TInner: ConnectionHandler,
{
#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
fn on_fully_negotiated_inbound(
&mut self,
FullyNegotiatedInbound {
Expand Down Expand Up @@ -232,7 +231,6 @@ where
panic!("Unexpected Either::Right in enabled `on_fully_negotiated_inbound`.")
}
}
#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
fn on_listen_upgrade_error(
&mut self,
ListenUpgradeError { info, error: err }: ListenUpgradeError<
Expand Down Expand Up @@ -268,7 +266,6 @@ where
}
}

#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
impl<TInner> ConnectionHandler for ToggleConnectionHandler<TInner>
where
TInner: ConnectionHandler,
Expand Down
4 changes: 0 additions & 4 deletions swarm/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ where
/// The underlying handler.
handler: THandler,
/// Futures that upgrade incoming substreams.
#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
negotiating_in: FuturesUnordered<
StreamUpgrade<
THandler::InboundOpenInfo,
Expand All @@ -132,7 +131,6 @@ where
>,
>,
/// Futures that upgrade outgoing substreams.
#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
negotiating_out: FuturesUnordered<
StreamUpgrade<
THandler::OutboundOpenInfo,
Expand All @@ -157,7 +155,6 @@ where
///
/// The upgrade timeout is already ticking here so this may fail in case the remote is not
/// quick enough in providing us with a new stream.
#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
requested_substreams: FuturesUnordered<
SubstreamRequested<THandler::OutboundOpenInfo, THandler::OutboundProtocol>,
>,
Expand All @@ -171,7 +168,6 @@ where
stream_counter: ActiveStreamCounter,
}

#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
impl<THandler> fmt::Debug for Connection<THandler>
where
THandler: ConnectionHandler + fmt::Debug,
Expand Down
1 change: 0 additions & 1 deletion swarm/src/connection/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,6 @@ where

/// Polls the connection pool for events.
#[tracing::instrument(level = "debug", name = "Pool::poll", skip(self, cx))]
#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
pub(crate) fn poll(&mut self, cx: &mut Context<'_>) -> Poll<PoolEvent<THandler::ToBehaviour>>
where
THandler: ConnectionHandler + 'static,
Expand Down
3 changes: 0 additions & 3 deletions swarm/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ use crate::{connection::AsStrHashEq, StreamProtocol};
/// Implementers of this trait should keep in mind that the connection can be closed at any time.
/// When a connection is closed gracefully, the substreams used by the handler may still
/// continue reading data until the remote closes its side of the connection.
#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
pub trait ConnectionHandler: Send + 'static {
/// A type representing the message(s) a
/// [`NetworkBehaviour`](crate::behaviour::NetworkBehaviour) can send to a [`ConnectionHandler`]
Expand All @@ -113,10 +112,8 @@ pub trait ConnectionHandler: Send + 'static {
/// The outbound upgrade for the protocol(s) used by the handler.
type OutboundProtocol: OutboundUpgradeSend;
/// The type of additional information returned from `listen_protocol`.
#[deprecated = "Track data in ConnectionHandler instead."]
type InboundOpenInfo: Send + 'static;
/// The type of additional information passed to an `OutboundSubstreamRequest`.
#[deprecated = "Track data in ConnectionHandler instead."]
type OutboundOpenInfo: Send + 'static;

/// The [`InboundUpgrade`](libp2p_core::upgrade::InboundUpgrade) to apply on inbound
Expand Down
1 change: 0 additions & 1 deletion swarm/src/handler/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ where

/// Implementation of a [`ConnectionHandler`] that represents either of two [`ConnectionHandler`]
/// implementations.
#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
impl<L, R> ConnectionHandler for Either<L, R>
where
L: ConnectionHandler,
Expand Down
1 change: 0 additions & 1 deletion swarm/src/handler/map_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ impl<TConnectionHandler, TMap, TNewIn> MapInEvent<TConnectionHandler, TNewIn, TM
}
}

#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
impl<TConnectionHandler, TMap, TNewIn> ConnectionHandler
for MapInEvent<TConnectionHandler, TNewIn, TMap>
where
Expand Down
1 change: 0 additions & 1 deletion swarm/src/handler/map_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ impl<TConnectionHandler, TMap> MapOutEvent<TConnectionHandler, TMap> {
}
}

#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
impl<TConnectionHandler, TMap, TNewOut> ConnectionHandler for MapOutEvent<TConnectionHandler, TMap>
where
TConnectionHandler: ConnectionHandler,
Expand Down
2 changes: 0 additions & 2 deletions swarm/src/handler/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ where
Ok(m)
}

#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
fn on_listen_upgrade_error(
&mut self,
ListenUpgradeError {
Expand All @@ -108,7 +107,6 @@ where
}
}

#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
impl<K, H> ConnectionHandler for MultiHandler<K, H>
where
K: Clone + Debug + Hash + Eq + Send + 'static,
Expand Down
2 changes: 0 additions & 2 deletions swarm/src/handler/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ where
TProto1: ConnectionHandler,
TProto2: ConnectionHandler,
{
#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
fn on_listen_upgrade_error(
&mut self,
ListenUpgradeError {
Expand Down Expand Up @@ -182,7 +181,6 @@ where
}
}

#[expect(deprecated)] // TODO: Remove when {In, Out}boundOpenInfo is fully removed.
impl<TProto1, TProto2> ConnectionHandler for ConnectionHandlerSelect<TProto1, TProto2>
where
TProto1: ConnectionHandler,
Expand Down

0 comments on commit 34252f0

Please sign in to comment.