2022-12-09 15:44:08 +01:00
# 0.42.0 [unreleased]
2023-02-14 14:09:29 +13:00
- Remove `handler` field from `NetworkBehaviourAction::Dial` .
Instead of constructing the handler early, you can now access the `ConnectionId` of the future connection on `DialOpts` .
`ConnectionId` s are `Copy` and will be used throughout the entire lifetime of the connection to report events.
This allows you to send events to a very specific connection, much like you previously could directly set state in the handler.
Removing the `handler` field also reduces the type parameters of `NetworkBehaviourAction` from three to two.
The third one used to be defaulted to the `InEvent` of the `ConnectionHandler` .
You now have to manually specify that where you previously had to specify the `ConnectionHandler` .
This very likely will trigger **convoluted compile errors** about traits not being implemented.
Within `NetworkBehaviourAction::poll` , the easiest way to migrate is to do this (in the example of `libp2p-floodsub` ):
```diff
--- a/protocols/floodsub/src/layer.rs
+++ b/protocols/floodsub/src/layer.rs
@@ -472,7 +465,7 @@ impl NetworkBehaviour for Floodsub {
& mut self,
_: &mut Context<'_ >,
_: & mut impl PollParameters,
- ) -> Poll< NetworkBehaviourAction < Self::OutEvent , Self::ConnectionHandler > > {
+ ) -> Poll< NetworkBehaviourAction < Self::OutEvent , THandlerInEvent < Self > >> {
```
In other words:
|Search|Replace|
|---|---|
|`NetworkBehaviourAction<Self::OutEvent, Self::ConnectionHandler>` |`NetworkBehaviourAction<Self::OutEvent, THandlerInEvent<Self>>` |
If you reference `NetworkBehaviourAction` somewhere else as well,
you may have to fill in the type of `ConnectionHandler::InEvent` manually as the 2nd parameter.
See [PR 3328].
2022-12-20 09:52:08 +01:00
- Update to `libp2p-core` `v0.39.0` .
2022-12-09 15:44:08 +01:00
- Removed deprecated Swarm constructors. For transition notes see [0.41.0 ](#0.41.0 ). See [PR 3170].
2023-01-20 09:49:11 +11:00
2022-12-14 11:50:08 +11:00
- Deprecate functions on `PollParameters` in preparation for `PollParameters` to be removed entirely eventually. See [PR 3153].
2022-12-09 15:44:08 +01:00
time to establish connection (#3134)
Implementing #2745 , adding a metric to break down time from connection pending to connection established, per protocol stack.
````
$curl -s http://127.0.0.1:42183/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Listener",protocols="/ip4/tcp"} 0.007
libp2p_swarm_connection_establishment_duration_count{role="Listener",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.008"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="+Inf"} 1
lbl@chomp:~lbl
$curl -s http://127.0.0.1:34283/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Dialer",protocols="/ip4/tcp"} 0.009
libp2p_swarm_connection_establishment_duration_count{role="Dialer",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.008"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="+Inf"} 1
````
2022-12-12 09:40:36 -05:00
- Add `estblished_in` to `SwarmEvent::ConnectionEstablished` . See [PR 3134].
2023-01-12 11:21:02 +00:00
- Remove deprecated `inject_*` methods from `NetworkBehaviour` and `ConnectionHandler` .
2023-01-24 01:10:26 +00:00
Make the implementation of `on_swarm_event` and `on_connection_handler_event`
both mandatory. See [PR 3264] and [PR 3364].
2023-01-12 11:21:02 +00:00
- Update to `libp2p-swarm-derive` `v0.32.0` .
2022-12-23 11:13:34 +11:00
- Remove type parameter from `PendingOutboundConnectionError` and `PendingInboundConnectionError` .
These two types are always used with `std::io::Error` . See [PR 3272].
2023-01-24 01:10:26 +00:00
- Replace `SwarmBuilder::connection_event_buffer_size` with `SwarmBuilder::per_connection_event_buffer_size` .
2023-01-20 09:49:11 +11:00
The configured value now applies _per_ connection.
The default values remains 7.
If you have previously set `connection_event_buffer_size` you should re-evaluate what a good size for a _per connection_ buffer is.
See [PR 3188].
2023-01-26 11:20:23 +04:00
- Add `PendingConnectionError::LocalPeerId` to differentiate wrong VS local peer ID errors. See [PR 3377].
2023-01-20 09:49:11 +11:00
2023-01-26 16:26:54 +11:00
- Remove `PendingConnectionError:::IO` variant.
This was never constructed.
See [PR 3373].
2023-01-26 19:10:08 +11:00
- Remove `DialError::ConnectionIo` variant.
This was never constructed.
See [PR 3374].
2023-01-27 10:23:55 +11:00
- Introduce `ListenError` and use it within `SwarmEvent::IncomingConnectionError` .
See [PR 3375].
2023-02-14 14:09:29 +13:00
- Remove `ConnectionId::new` . Manually creating `ConnectionId` s is now unsupported. See [PR 3327].
2023-01-24 01:10:26 +00:00
[PR 3364]: https://github.com/libp2p/rust-libp2p/pull/3364
2022-12-09 15:44:08 +01:00
[PR 3170]: https://github.com/libp2p/rust-libp2p/pull/3170
time to establish connection (#3134)
Implementing #2745 , adding a metric to break down time from connection pending to connection established, per protocol stack.
````
$curl -s http://127.0.0.1:42183/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Listener",protocols="/ip4/tcp"} 0.007
libp2p_swarm_connection_establishment_duration_count{role="Listener",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.008"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="+Inf"} 1
lbl@chomp:~lbl
$curl -s http://127.0.0.1:34283/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Dialer",protocols="/ip4/tcp"} 0.009
libp2p_swarm_connection_establishment_duration_count{role="Dialer",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.008"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="+Inf"} 1
````
2022-12-12 09:40:36 -05:00
[PR 3134]: https://github.com/libp2p/rust-libp2p/pull/3134
2022-12-14 11:50:08 +11:00
[PR 3153]: https://github.com/libp2p/rust-libp2p/pull/3153
2023-01-12 11:21:02 +00:00
[PR 3264]: https://github.com/libp2p/rust-libp2p/pull/3264
2022-12-23 11:13:34 +11:00
[PR 3272]: https://github.com/libp2p/rust-libp2p/pull/3272
2023-01-24 03:29:41 +11:00
[PR 3327]: https://github.com/libp2p/rust-libp2p/pull/3327
2023-02-14 14:09:29 +13:00
[PR 3328]: https://github.com/libp2p/rust-libp2p/pull/3328
2023-01-20 09:49:11 +11:00
[PR 3188]: https://github.com/libp2p/rust-libp2p/pull/3188
2023-01-26 11:20:23 +04:00
[PR 3377]: https://github.com/libp2p/rust-libp2p/pull/3377
2023-01-26 16:26:54 +11:00
[PR 3373]: https://github.com/libp2p/rust-libp2p/pull/3373
2023-01-26 19:10:08 +11:00
[PR 3374]: https://github.com/libp2p/rust-libp2p/pull/3374
2023-01-27 10:23:55 +11:00
[PR 3375]: https://github.com/libp2p/rust-libp2p/pull/3375
2022-12-09 15:44:08 +01:00
2022-11-29 17:45:58 +01:00
# 0.41.1
- Update to `libp2p-swarm-derive` `v0.31.0` .
2022-11-25 10:37:55 +01:00
# 0.41.0
2022-11-02 23:02:21 +11:00
- Update to `libp2p-core` `v0.38.0` .
2022-11-17 17:19:36 +00:00
- Add new `on_connection_event` method to `ConnectionHandler` that accepts a `ConnectionEvent` enum and update
`inject_*` methods to call `on_connection_event` with the respective `ConnectionEvent` variant and deprecate
`inject_*` .
To migrate, users should replace the `ConnectionHandler::inject_*` calls with a single
implementation of `ConnectionHandler::on_connection_event` treating each `ConnectionEvent` variant in
the same way its corresponding `inject_*` call was treated.
See [PR 3085].
- Add new `on_behaviour_event` method with the same signature as `inject_event` , make the
default implementation of `inject_event` call `on_behaviour_event` and deprecate it.
To migrate, users should replace the `ConnectionHandler::inject_event` call
with `ConnectionHandler::on_behaviour_event` .
See [PR 3085].
2022-11-17 09:28:40 +00:00
- Add new `on_swarm_event` method to `NetworkBehaviour` that accepts a `FromSwarm` enum and update
`inject_*` methods to call `on_swarm_event` with the respective `FromSwarm` variant and deprecate
`inject_*` .
To migrate, users should replace the `NetworkBehaviour::inject_*` calls with a single
implementation of `NetworkBehaviour::on_swarm_event` treating each `FromSwarm` variant in
the same way its corresponding `inject_*` call was treated.
See [PR 3011].
- Add new `on_connection_handler_event` method with the same signature as `inject_event` , make the
default implementation of `inject_event` call `on_connection_handler_event` and deprecate it.
To migrate, users should replace the `NetworkBehaviour::inject_event` call
with `NetworkBehaviour::on_connection_handler_event` .
See [PR 3011].
2022-11-13 10:59:14 +11:00
- Export `NetworkBehaviour` derive as `libp2p_swarm::NetworkBehaviour` .
This follows the convention of other popular libraries. `serde` for example exports the `Serialize` trait and macro as
`serde::Serialize` . See [PR 3055].
2022-11-15 15:26:03 +01:00
2022-11-13 10:59:14 +11:00
- Feature-gate `NetworkBehaviour` macro behind `macros` feature flag. See [PR 3055].
2022-11-15 15:26:03 +01:00
- Make executor in Swarm constructor explicit. See [PR 3097].
2022-11-17 09:28:40 +00:00
2022-11-15 15:26:03 +01:00
Supported executors:
- Tokio
Previously
```rust
let swarm = SwarmBuilder::new(transport, behaviour, peer_id)
.executor(Box::new(|fut| {
tokio::spawn(fut);
}))
.build();
```
Now
```rust
let swarm = Swarm::with_tokio_executor(transport, behaviour, peer_id);
```
- Async Std
2022-11-17 09:28:40 +00:00
2022-11-15 15:26:03 +01:00
Previously
```rust
let swarm = SwarmBuilder::new(transport, behaviour, peer_id)
.executor(Box::new(|fut| {
async_std::task::spawn(fut);
}))
.build();
```
Now
```rust
let swarm = Swarm::with_async_std_executor(transport, behaviour, peer_id);
```
- ThreadPool (see [Issue 3107])
2022-11-17 09:28:40 +00:00
2022-11-15 15:26:03 +01:00
In most cases ThreadPool can be replaced by executors or spawning on the local task.
Previously
```rust
let swarm = Swarm::new(transport, behaviour, peer_id);
```
Now
```rust
let swarm = Swarm::with_threadpool_executor(transport, behaviour, peer_id);
```
- Without
2022-11-17 09:28:40 +00:00
2022-11-15 15:26:03 +01:00
Spawns the tasks on the current task, this may result in bad performance so try to use an executor where possible. Previously this was just a fallback when no executor was specified and constructing a `ThreadPool` failed.
New
```rust
let swarm = Swarm::without_executor(transport, behaviour, peer_id);
```
2022-11-17 09:28:40 +00:00
2022-11-15 15:26:03 +01:00
Deprecated APIs:
- `Swarm::new`
- `SwarmBuilder::new`
- `SwarmBuilder::executor`
2022-11-18 22:04:16 +11:00
- Update `rust-version` to reflect the actual MSRV: 1.62.0. See [PR 3090].
2022-11-17 17:19:36 +00:00
[PR 3085]: https://github.com/libp2p/rust-libp2p/pull/3085
2022-11-17 09:28:40 +00:00
[PR 3011]: https://github.com/libp2p/rust-libp2p/pull/3011
2022-11-13 10:59:14 +11:00
[PR 3055]: https://github.com/libp2p/rust-libp2p/pull/3055
2022-11-15 15:26:03 +01:00
[PR 3097]: https://github.com/libp2p/rust-libp2p/pull/3097
[Issue 3107]: https://github.com/libp2p/rust-libp2p/issues/3107
2022-11-18 22:04:16 +11:00
[PR 3090]: https://github.com/libp2p/rust-libp2p/pull/3090
2022-11-13 10:59:14 +11:00
2022-11-02 13:41:28 +00:00
# 0.40.1
2022-09-22 12:48:32 +04:00
- Bump rand to 0.8 and quickcheck to 1. See [PR 2857].
2022-09-30 01:32:22 +10:00
- Update to `libp2p-core` `v0.37.0` .
2022-10-14 15:30:16 +01:00
- Introduce `libp2p_swarm::keep_alive::ConnectionHandler` in favor of removing `keep_alive` from
2022-10-06 03:50:11 +11:00
`libp2p_swarm::dummy::ConnectionHandler` . `dummy::ConnectionHandler` now literally does not do anything. In the same
spirit, introduce `libp2p_swarm::keep_alive::Behaviour` and `libp2p_swarm::dummy::Behaviour` . See [PR 2859].
2022-09-22 12:48:32 +04:00
[PR 2857]: https://github.com/libp2p/rust-libp2p/pull/2857
2022-10-06 03:50:11 +11:00
[PR 2859]: https://github.com/libp2p/rust-libp2p/pull/2859/
2022-09-22 12:48:32 +04:00
2022-09-23 06:57:52 -04:00
- Pass actual `PeerId` of dial to `NetworkBehaviour::inject_dial_failure` on `DialError::ConnectionLimit` . See [PR 2928].
[PR 2928]: https://github.com/libp2p/rust-libp2p/pull/2928
2022-09-07 09:44:51 +02:00
# 0.39.0
2022-08-26 07:08:33 +02:00
- Remove deprecated `NetworkBehaviourEventProcess` . See [libp2p-swarm v0.38.0 changelog entry] for
migration path.
2022-09-07 09:16:22 +03:00
- Update to `libp2p-core` `v0.36.0` .
2022-09-21 23:02:21 +10:00
- Enforce backpressure on incoming streams via `StreamMuxer` interface. In case we hit the configured limit of maximum
number of inbound streams, we will stop polling the `StreamMuxer` for new inbound streams. Depending on the muxer
implementation in use, this may lead to instant dropping of inbound streams. See [PR 2861].
2022-08-26 07:08:33 +02:00
[libp2p-swarm v0.38.0 changelog entry]: https://github.com/libp2p/rust-libp2p/blob/master/swarm/CHANGELOG.md#0380
2022-09-21 23:02:21 +10:00
[PR 2861]: https://github.com/libp2p/rust-libp2p/pull/2861/
2022-08-26 07:08:33 +02:00
2022-08-22 05:14:04 +02:00
# 0.38.0
2022-07-07 04:20:03 -05:00
2022-08-16 06:58:17 +02:00
- Deprecate `NetworkBehaviourEventProcess` . When deriving `NetworkBehaviour` on a custom `struct` users
should either bring their own `OutEvent` via `#[behaviour(out_event = "MyBehaviourEvent")]` or,
when not specified, have the derive macro generate one for the user.
2022-07-07 04:20:03 -05:00
2022-08-16 06:58:17 +02:00
See [`NetworkBehaviour`
documentation](https://docs.rs/libp2p/latest/libp2p/swarm/trait.NetworkBehaviour.html) and [PR
2784] for details.
Previously
``` rust
#[derive(NetworkBehaviour)]
#[behaviour(event_process = true)]
struct MyBehaviour {
gossipsub: Gossipsub,
mdns: Mdns,
}
impl NetworkBehaviourEventProcess< Gossipsub > for MyBehaviour {
fn inject_event(& mut self, message: GossipsubEvent) {
todo!("Handle event")
}
}
impl NetworkBehaviourEventProcess< MdnsEvent > for MyBehaviour {
fn inject_event(& mut self, message: MdnsEvent) {
todo!("Handle event")
}
}
```
Now
``` rust
#[derive(NetworkBehaviour)]
#[behaviour(out_event = "MyBehaviourEvent")]
struct MyBehaviour {
gossipsub: Gossipsub,
mdns: Mdns,
}
enum MyBehaviourEvent {
Gossipsub(GossipsubEvent),
Mdns(MdnsEvent),
}
impl From< GossipsubEvent > for MyBehaviourEvent {
fn from(event: GossipsubEvent) -> Self {
MyBehaviourEvent::Gossipsub(event)
}
}
impl From< MdnsEvent > for MyBehaviourEvent {
fn from(event: MdnsEvent) -> Self {
MyBehaviourEvent::Mdns(event)
}
}
match swarm.next().await.unwrap() {
SwarmEvent::Behaviour(MyBehaviourEvent::Gossipsub(event)) => {
todo!("Handle event")
}
SwarmEvent::Behaviour(MyBehaviourEvent::Mdns(event)) => {
todo!("Handle event")
}
}
```
2022-07-18 04:20:11 +01:00
2022-08-08 07:18:32 +02:00
- When deriving `NetworkBehaviour` on a custom `struct` where the user does not specify their own
`OutEvent` via `#[behaviour(out_event = "MyBehaviourEvent")]` and where the user does not enable
`#[behaviour(event_process = true)]` , then the derive macro generates an `OutEvent` definition for
the user.
See [`NetworkBehaviour`
2022-08-16 06:58:17 +02:00
documentation](https://docs.rs/libp2p/latest/libp2p/swarm/trait.NetworkBehaviour.html) and [PR
2792] for details.
- Update dial address concurrency factor to `8` , thus dialing up to 8 addresses concurrently for a single connection attempt. See `Swarm::dial_concurrency_factor` and [PR 2741].
- Update to `libp2p-core` `v0.35.0` .
2022-08-08 07:18:32 +02:00
2022-07-07 04:20:03 -05:00
[PR 2741]: https://github.com/libp2p/rust-libp2p/pull/2741/
2022-08-16 06:58:17 +02:00
[PR 2784]: https://github.com/libp2p/rust-libp2p/pull/2784
[PR 2792]: https://github.com/libp2p/rust-libp2p/pull/2792
2022-07-07 04:20:03 -05:00
2022-07-05 13:09:58 +02:00
# 0.37.0
2022-06-23 13:52:11 +02:00
- Update to `libp2p-core` `v0.34.0` .
2022-06-22 06:02:55 +02:00
- Extend log message when exceeding inbound negotiating streams with peer ID and limit. See [PR 2716].
2022-07-04 04:16:57 +02:00
- Remove `connection::ListenersStream` and poll the `Transport` directly. See [PR 2652].
2022-06-22 06:02:55 +02:00
[PR 2716]: https://github.com/libp2p/rust-libp2p/pull/2716/
2022-07-04 04:16:57 +02:00
[PR 2652]: https://github.com/libp2p/rust-libp2p/pull/2652
2022-06-22 06:02:55 +02:00
2022-06-09 15:26:56 +02:00
# 0.36.1
2022-06-08 11:48:46 +02:00
- Limit negotiating inbound substreams per connection. See [PR 2697].
[PR 2697]: https://github.com/libp2p/rust-libp2p/pull/2697
2022-05-31 13:12:53 +02:00
# 0.36.0
2022-04-06 20:23:16 +02:00
- Don't require `Transport` to be `Clone` . See [PR 2529].
- Update to `libp2p-core` `v0.33.0` .
2022-04-08 01:06:06 +02:00
- Make `behaviour::either` module private. See [PR 2610]
2022-05-03 13:11:48 +02:00
- Rename `IncomingInfo::to_connected_point` to `IncomingInfo::create_connected_point` . See [PR 2620].
2022-05-18 02:52:50 -05:00
- Rename `TProtoHandler` to `TConnectionHandler` , `ToggleProtoHandler` to `ToggleConnectionHandler` , `ToggleIntoProtoHandler` to `ToggleIntoConnectionHandler` . See [PR 2640].
2022-04-06 20:23:16 +02:00
[PR 2529]: https://github.com/libp2p/rust-libp2p/pull/2529
2022-05-03 13:11:48 +02:00
[PR 2610]: https://github.com/libp2p/rust-libp2p/pull/2610
[PR 2620]: https://github.com/libp2p/rust-libp2p/pull/2620
2022-05-18 02:52:50 -05:00
[PR 2640]: https://github.com/libp2p/rust-libp2p/pull/2640
2022-04-06 20:23:16 +02:00
2022-04-04 18:27:41 +02:00
# 0.35.0
2022-02-28 10:27:58 +01:00
2022-03-21 20:50:44 +03:00
- Add impl `IntoIterator` for `MultiHandler` . See [PR 2572].
2022-02-28 10:27:58 +01:00
- Remove `Send` bound from `NetworkBehaviour` . See [PR 2535].
2022-03-21 20:50:44 +03:00
[PR 2572]: https://github.com/libp2p/rust-libp2p/pull/2572/
2022-02-28 10:27:58 +01:00
[PR 2535]: https://github.com/libp2p/rust-libp2p/pull/2535/
2022-02-22 14:05:19 +01:00
# 0.34.0 [2022-02-22]
2022-02-03 16:38:41 +00:00
2022-02-21 13:32:24 +01:00
- Rename `ProtocolsHandler` to `ConnectionHandler` . Upgrade should be as simple as renaming all
occurences of `ProtocolsHandler` to `ConnectionHandler` with your favorite text manipulation tool
across your codebase. See [PR 2527].
2022-02-13 21:57:38 +01:00
- Fold `libp2p-core` 's `Network` into `Swarm` . See [PR 2492].
2022-02-03 16:38:41 +00:00
- Update to `libp2p-core` `v0.32.0` .
2022-02-15 10:19:55 +01:00
- Disconnect pending connections with `Swarm::disconnect` . See [PR 2517].
- Report aborted connections via `SwarmEvent::OutgoingConnectionError` . See [PR 2517].
2022-02-13 21:57:38 +01:00
[PR 2492]: https://github.com/libp2p/rust-libp2p/pull/2492
2022-02-15 10:19:55 +01:00
[PR 2517]: https://github.com/libp2p/rust-libp2p/pull/2517
2022-02-21 13:32:24 +01:00
[PR 2527]: https://github.com/libp2p/rust-libp2p/pull/2527
2022-02-13 21:57:38 +01:00
2022-01-27 11:29:09 +01:00
# 0.33.0 [2022-01-27]
2021-11-26 10:48:12 -05:00
2021-11-26 09:34:58 -07:00
- Patch reporting on banned peers and their non-banned and banned connections (see [PR 2350]).
2021-11-26 10:48:12 -05:00
- Update dependencies.
2021-11-26 09:34:58 -07:00
- Migrate to Rust edition 2021 (see [PR 2339]).
2021-11-29 18:59:44 +01:00
- Update `Connection::address` on `inject_address_change` (see [PR 2362]).
2021-12-09 03:00:47 -08:00
- Move `swarm::Toggle` to `swarm::behaviour::Toggle` (see [PR 2375]).
2021-12-13 17:17:12 +01:00
- Add `Swarm::connected_peers` (see [PR 2378]).
2021-12-12 03:51:02 -08:00
- Implement `swarm::NetworkBehaviour` on `either::Either` (see [PR 2370]).
2022-01-17 16:35:14 +01:00
- Allow overriding _dial concurrency factor_ per dial via
2022-01-13 18:07:07 +01:00
`DialOpts::override_dial_concurrency_factor` . See [PR 2404].
2022-01-18 21:21:11 +01:00
- Report negotiated and expected `PeerId` as well as remote address in
`DialError::WrongPeerId` (see [PR 2428]).
2022-01-17 16:35:14 +01:00
- Allow overriding role when dialing through `override_role` option on
`DialOpts` . This option is needed for NAT and firewall hole punching. See [PR
2363].
2022-02-09 10:08:28 -05:00
- Merge NetworkBehaviour's inject_\* paired methods (see PR 2445).
2021-11-26 09:34:58 -07:00
[PR 2339]: https://github.com/libp2p/rust-libp2p/pull/2339
2021-11-26 10:48:12 -05:00
[PR 2350]: https://github.com/libp2p/rust-libp2p/pull/2350
2021-11-29 18:59:44 +01:00
[PR 2362]: https://github.com/libp2p/rust-libp2p/pull/2362
2021-12-12 03:51:02 -08:00
[PR 2370]: https://github.com/libp2p/rust-libp2p/pull/2370
2021-12-09 03:00:47 -08:00
[PR 2375]: https://github.com/libp2p/rust-libp2p/pull/2375
2021-12-13 17:17:12 +01:00
[PR 2378]: https://github.com/libp2p/rust-libp2p/pull/2378
2022-01-13 18:07:07 +01:00
[PR 2404]: https://github.com/libp2p/rust-libp2p/pull/2404
2022-01-18 21:21:11 +01:00
[PR 2428]: https://github.com/libp2p/rust-libp2p/pull/2428
2022-01-17 16:35:14 +01:00
[PR 2363]: https://github.com/libp2p/rust-libp2p/pull/2363
2022-02-09 10:08:28 -05:00
[PR 2445]: https://github.com/libp2p/rust-libp2p/pull/2445
2021-11-26 10:48:12 -05:00
2021-11-16 16:39:42 +01:00
# 0.32.0 [2021-11-16]
2021-10-30 12:41:30 +02:00
- Use `instant` and `futures-timer` instead of `wasm-timer` (see [PR 2245]).
2021-11-15 14:17:23 +01:00
- Enable advanced dialing requests both on `Swarm::dial` and via
`NetworkBehaviourAction::Dial` . Users can now trigger a dial with a specific
set of addresses, optionally extended via
`NetworkBehaviour::addresses_of_peer` .
Changes required to maintain status quo:
2022-01-18 21:21:11 +01:00
- Previously `swarm.dial(peer_id)`
2021-11-15 14:17:23 +01:00
now `swarm.dial(DialOpts::peer_id(peer_id).build())`
or `swarm.dial(peer_id)` given that `DialOpts` implements `From<PeerId>` .
2022-01-18 21:21:11 +01:00
- Previously `swarm.dial_addr(addr)`
2021-11-15 14:17:23 +01:00
now `swarm.dial(DialOpts::unknown_peer_id().address(addr).build())`
or `swarm.dial(addr)` given that `DialOpts` implements `From<Multiaddr>` .
2022-01-18 21:21:11 +01:00
- Previously `NetworkBehaviourAction::DialPeer { peer_id, condition, handler }`
2021-11-15 14:17:23 +01:00
now
2022-01-18 21:21:11 +01:00
2021-11-15 14:17:23 +01:00
```rust
NetworkBehaviourAction::Dial {
opts: DialOpts::peer_id(peer_id)
.condition(condition)
.build(),
handler,
}
```
2022-01-18 21:21:11 +01:00
- Previously `NetworkBehaviourAction::DialAddress { address, handler }`
2021-11-15 14:17:23 +01:00
now
2022-01-18 21:21:11 +01:00
2021-11-15 14:17:23 +01:00
```rust
NetworkBehaviourAction::Dial {
opts: DialOpts::unknown_peer_id()
.address(address)
.build(),
handler,
}
```
See [PR 2317].
2021-10-30 12:41:30 +02:00
[PR 2245]: https://github.com/libp2p/rust-libp2p/pull/2245
2021-11-15 14:17:23 +01:00
[PR 2317]: https://github.com/libp2p/rust-libp2p/pull/2317
2021-10-30 12:41:30 +02:00
2021-11-02 20:40:48 +01:00
# 0.31.0 [2021-11-01]
2021-07-22 22:34:13 +02:00
2021-08-18 12:08:45 +02:00
- Make default features of `libp2p-core` optional.
[PR 2181 ](https://github.com/libp2p/rust-libp2p/pull/2181 )
2021-07-22 22:34:13 +02:00
- Update dependencies.
2021-07-31 03:48:32 +10:00
- Provide default implementations for all functions of `NetworkBehaviour` ,
except for `new_handler` , `inject_event` and `poll` .
This should make it easier to create new implementations. See [PR 2150].
2021-08-09 15:29:58 +02:00
- Remove `Swarm` type alias and rename `ExpandedSwarm` to `Swarm` . Reduce direct
trait parameters on `Swarm` (previously `ExpandedSwarm` ), deriving parameters
through associated types on `TBehaviour` . See [PR 2182].
2021-08-11 12:41:28 +02:00
- Require `ProtocolsHandler::{InEvent,OutEvent,Error}` to implement `Debug` (see
[PR 2183]).
2021-08-17 18:02:06 +02:00
- Implement `ProtocolsHandler` on `either::Either` representing either of two
`ProtocolsHandler` implementations (see [PR 2192]).
2021-08-31 17:00:51 +02:00
- Require implementation to provide handler in
`NetworkBehaviourAction::DialPeer` and `NetworkBehaviourAction::DialAddress` .
Note that the handler is returned to the `NetworkBehaviour` on connection
failure and connection closing. Thus it can be used to carry state, which
otherwise would have to be tracked in the `NetworkBehaviour` itself. E.g. a
message destined to an unconnected peer can be included in the handler, and
thus directly send on connection success or extracted by the
`NetworkBehaviour` on connection failure (see [PR 2191]).
- Include handler in `NetworkBehaviour::inject_dial_failure` ,
`NetworkBehaviour::inject_connection_closed` ,
`NetworkBehaviour::inject_listen_failure` (see [PR 2191]).
- Include error in `NetworkBehaviour::inject_dial_failure` and call
`NetworkBehaviour::inject_dial_failure` on `DialPeerCondition` evaluating to
false. To emulate the previous behaviour, return early within
`inject_dial_failure` on `DialError::DialPeerConditionFalse` . See [PR 2191].
- Make `NetworkBehaviourAction` generic over `NetworkBehaviour::OutEvent` and
`NetworkBehaviour::ProtocolsHandler` . In most cases, change your generic type
parameters to `NetworkBehaviourAction< Self::OutEvent ,
Self::ProtocolsHandler>`. See [PR 2191].
2021-10-11 22:38:55 +02:00
- Return `bool` instead of `Result<(), ()>` for `Swarm::remove_listener` (see
[PR 2261]).
2021-10-14 18:05:07 +02:00
- Concurrently dial address candidates within a single dial attempt (see [PR 2248]) configured via
`Swarm::dial_concurrency_factor` .
- On success of a single address, report errors of the thus far failed dials via
`SwarmEvent::ConnectionEstablished::outgoing` .
- On failure of all addresses, report errors via the new `SwarmEvent::OutgoingConnectionError` .
- Remove `SwarmEvent::UnreachableAddr` and `SwarmEvent::UnknownPeerUnreachableAddr` event.
- In `NetworkBehaviour::inject_connection_established` provide errors of all thus far failed addresses.
- On unknown peer dial failures, call `NetworkBehaviour::inject_dial_failure` with a peer ID of `None` .
- Remove `NetworkBehaviour::inject_addr_reach_failure` . Information is now provided via
`NetworkBehaviour::inject_connection_established` and `NetworkBehaviour::inject_dial_failure` .
2021-08-17 18:02:06 +02:00
[PR 2150]: https://github.com/libp2p/rust-libp2p/pull/2150
2021-08-09 15:29:58 +02:00
[PR 2182]: https://github.com/libp2p/rust-libp2p/pull/2182
2021-08-11 12:41:28 +02:00
[PR 2183]: https://github.com/libp2p/rust-libp2p/pull/2183
2021-08-17 18:02:06 +02:00
[PR 2192]: https://github.com/libp2p/rust-libp2p/pull/2192
2021-08-31 17:00:51 +02:00
[PR 2191]: https://github.com/libp2p/rust-libp2p/pull/2191
2021-10-14 18:05:07 +02:00
[PR 2248]: https://github.com/libp2p/rust-libp2p/pull/2248
2021-10-11 22:38:55 +02:00
[PR 2261]: https://github.com/libp2p/rust-libp2p/pull/2261
2021-07-31 03:48:32 +10:00
2021-07-12 21:24:58 +02:00
# 0.30.0 [2021-07-12]
2021-05-27 14:04:33 +02:00
- Update dependencies.
2021-06-14 20:41:44 +02:00
- Drive `ExpandedSwarm` via `Stream` trait only.
- Change `Stream` implementation of `ExpandedSwarm` to return all
`SwarmEvents` instead of only the `NetworkBehaviour` 's events.
- Remove `ExpandedSwarm::next_event` . Users can use `< ExpandedSwarm as
StreamExt>::next` instead.
- Remove `ExpandedSwarm::next` . Users can use `< ExpandedSwarm as
StreamExt>::filter_map` instead.
See [PR 2100] for details.
2021-07-03 00:35:51 +07:00
- Add `ExpandedSwarm::disconnect_peer_id` and
`NetworkBehaviourAction::CloseConnection` to close connections to a specific
peer via an `ExpandedSwarm` or `NetworkBehaviour` . See [PR 2110] for details.
2021-07-08 11:41:33 +02:00
- Expose the `ListenerId` in `SwarmEvent` s that are associated with a listener.
2021-07-12 21:24:58 +02:00
2021-07-08 11:41:33 +02:00
See [PR 2123] for details.
2021-06-14 20:41:44 +02:00
[PR 2100]: https://github.com/libp2p/rust-libp2p/pull/2100
2021-07-03 00:35:51 +07:00
[PR 2110]: https://github.com/libp2p/rust-libp2p/pull/2110/
2021-07-08 11:41:33 +02:00
[PR 2123]: https://github.com/libp2p/rust-libp2p/pull/2123
2021-06-14 20:41:44 +02:00
2021-04-13 20:15:15 +02:00
# 0.29.0 [2021-04-13]
2021-03-18 14:55:33 +01:00
- Remove `Deref` and `DerefMut` implementations previously dereferencing to the
`NetworkBehaviour` on `Swarm` . Instead one can access the `NetworkBehaviour`
via `Swarm::behaviour` and `Swarm::behaviour_mut` . Methods on `Swarm` can now
be accessed directly, e.g. via `my_swarm.local_peer_id()` . You may use the
command below to transform fully qualified method calls on `Swarm` to simple
2021-03-24 17:33:15 +01:00
method calls [PR 1995 ](https://github.com/libp2p/rust-libp2p/pull/1995 ).
2021-05-27 14:04:33 +02:00
2021-03-18 14:55:33 +01:00
``` bash
# Go from e.g. `Swarm::local_peer_id(&my_swarm)` to `my_swarm.local_peer_id()` .
grep -RiIl --include \*.rs --exclude-dir target . --exclude-dir .git | xargs sed -i "s/\(libp2p::\)*Swarm::\([a-z_]*\)(& mut \([a-z_0-9]*\), /\3.\2(/g"
```
2021-05-27 14:04:33 +02:00
2021-03-24 17:33:15 +01:00
- Extend `NetworkBehaviour` callbacks, more concretely introducing new `fn
inject_new_listener` and ` fn inject_expired_external_addr` and have ` fn
inject_{new,expired}_listen_addr` provide a ` ListenerId` [PR
2011](https://github.com/libp2p/rust-libp2p/pull/2011).
2021-03-18 14:55:33 +01:00
2021-03-17 15:28:13 +01:00
# 0.28.0 [2021-03-17]
2021-02-25 11:35:52 +01:00
2021-03-17 10:53:19 +01:00
- New error variant `DialError::InvalidAddress`
- `Swarm::dial_addr()` now returns a `DialError` on error.
2021-02-25 11:35:52 +01:00
- Remove the option for a substream-specific multistream select protocol override.
The override at this granularity is no longer deemed useful, in particular because
it can usually not be configured for existing protocols like `libp2p-kad` and others.
There is a `Swarm` -scoped configuration for this version available since
[1858 ](https://github.com/libp2p/rust-libp2p/pull/1858 ).
2021-02-04 12:42:31 +01:00
# 0.27.2 [2021-02-04]
- Have `ToggleProtoHandler` ignore listen upgrade errors when disabled.
[PR 1945 ](https://github.com/libp2p/rust-libp2p/pull/1945/files ).
2021-01-27 12:46:14 +01:00
# 0.27.1 [2021-01-27]
2021-01-27 10:44:08 +01:00
- Make `OneShotHandler` s `max_dial_negotiate` limit configurable.
[PR 1936 ](https://github.com/libp2p/rust-libp2p/pull/1936 ).
2021-01-27 12:46:14 +01:00
2021-01-27 12:05:35 +02:00
- Fix handling of DialPeerCondition::Always.
[PR 1937 ](https://github.com/libp2p/rust-libp2p/pull/1937 ).
2021-01-27 10:44:08 +01:00
2021-01-12 20:33:43 +01:00
# 0.27.0 [2021-01-12]
2021-01-12 12:48:37 +01:00
- Update dependencies.
2020-12-18 10:03:20 +01:00
# 0.26.0 [2020-12-17]
2020-12-15 14:40:39 +01:00
- Update `libp2p-core` .
2020-12-17 11:01:45 +01:00
- Remove `NotifyHandler::All` thus removing the requirement for events send from
a `NetworkBehaviour` to a `ProtocolsHandler` to be `Clone` .
[PR 1880 ](https://github.com/libp2p/rust-libp2p/pull/1880 ).
2020-11-26 21:01:38 +01:00
# 0.25.1 [2020-11-26]
- Add `ExpandedSwarm::is_connected` .
[PR 1862 ](https://github.com/libp2p/rust-libp2p/pull/1862 ).
2020-11-25 15:30:13 +01:00
# 0.25.0 [2020-11-25]
2020-11-17 11:15:20 +01:00
2020-11-25 14:26:49 +01:00
- Permit a configuration override for the substream upgrade protocol
to use for all (outbound) substreams.
[PR 1858 ](https://github.com/libp2p/rust-libp2p/pull/1858 ).
2020-11-23 17:22:15 +01:00
- Changed parameters for connection limits from `usize` to `u32` .
Connection limits are now configured via `SwarmBuilder::connection_limits()` .
2020-11-17 11:15:20 +01:00
- Update `libp2p-core` .
2020-11-18 15:52:33 +01:00
- Expose configurable scores for external addresses, as well as
the ability to remove them and to add addresses that are
retained "forever" (or until explicitly removed).
[PR 1842 ](https://github.com/libp2p/rust-libp2p/pull/1842 ).
2020-11-09 17:46:07 +01:00
# 0.24.0 [2020-11-09]
2020-10-31 01:51:27 +11:00
- Update dependencies.
2020-10-16 20:36:47 +02:00
# 0.23.0 [2020-10-16]
2020-10-16 16:53:02 +02:00
- Require a `Boxed` transport to be given to the `Swarm`
or `SwarmBuilder` to avoid unnecessary double-boxing of
transports and simplify API bounds.
[PR 1794 ](https://github.com/libp2p/rust-libp2p/pull/1794 )
2020-10-09 19:37:17 +02:00
2020-10-12 11:39:50 +02:00
- Respect inbound timeouts and upgrade versions in the `MultiHandler` .
[PR 1786 ](https://github.com/libp2p/rust-libp2p/pull/1786 ).
2020-10-09 19:37:17 +02:00
- Instead of iterating each inbound and outbound substream upgrade looking for
one to make progress, use a `FuturesUnordered` for both pending inbound and
pending outbound upgrades. As a result only those upgrades are polled that are
ready to progress.
Implementors of `InboundUpgrade` and `OutboundUpgrade` need to ensure to wake
up the underlying task once they are ready to make progress as they won't be
polled otherwise.
[PR 1775 ](https://github.com/libp2p/rust-libp2p/pull/1775 )
2020-09-09 12:20:25 +02:00
# 0.22.0 [2020-09-09]
2020-08-23 16:57:20 +02:00
2020-09-03 12:31:04 +02:00
- Bump `libp2p-core` dependency.
2020-08-23 16:57:20 +02:00
- Adds `ProtocolsHandler::InboundOpenInfo` type which mirrors the existing
`OutboundOpenInfo` type. A value of this type is passed as an extra argument
to `ProtocolsHandler::inject_fully_negotiated_inbound` and
`ProtocolsHandler::inject_listen_upgrade_error` .
2020-09-03 12:31:04 +02:00
2020-08-23 16:57:20 +02:00
- `SubstreamProtocol` now has a second type parameter corresponding to
inbound or outbound information, a value of which is part of `SubstreamProtocol`
now. Consequently `ProtocolsHandlerEvent::OutboundSubstreamRequest` no longer
has a separate `info` field.
2020-08-18 17:04:34 +02:00
# 0.21.0 [2020-08-18]
2020-08-04 11:30:09 +02:00
2020-08-18 16:28:22 +02:00
- Add missing delegation calls in some `ProtocolsHandler` wrappers.
See [PR 1710 ](https://github.com/libp2p/rust-libp2p/pull/1710 ).
2020-08-10 10:13:50 +02:00
- Add as_ref and as_mut functions to Toggle
[PR 1684 ](https://github.com/libp2p/rust-libp2p/pull/1684 ).
2020-08-04 11:30:09 +02:00
- The `cause` of `SwarmEvent::ConnectionClosed` is now an `Option` ,
and `None` indicates an active connection close not caused by an
error.
- `DialError::Banned` has been added and is returned from `Swarm::dial`
if the peer is banned, thereby also invoking the `NetworkBehaviour::inject_dial_failure`
callback.
- Update the `libp2p-core` dependency to `0.21` , fixing [1584 ](https://github.com/libp2p/rust-libp2p/issues/1584 ).
2020-08-13 11:18:20 +02:00
- Fix connections being kept alive by `OneShotHandler` when not handling any
requests [PR 1698 ](https://github.com/libp2p/rust-libp2p/pull/1698 ).
2020-07-08 19:32:47 +10:00
# 0.20.1 [2020-07-08]
- Documentation updates.
2020-07-08 11:51:49 +02:00
- Ignore addresses returned by `NetworkBehaviour::addresses_of_peer`
that the `Swarm` considers to be listening addresses of the local node. This
avoids futile dialing attempts of a node to itself, which can otherwise
even happen in genuine situations, e.g. after the local node changed
its network identity and a behaviour makes a dialing attempt to a
former identity using the same addresses.
2020-07-01 15:36:20 +02:00
# 0.20.0 [2020-07-01]
- Updated the `libp2p-core` dependency.
2020-06-29 17:08:40 +02:00
- Add `ProtocolsHandler::inject_listen_upgrade_error` , the inbound
analogue of `ProtocolsHandler::inject_dial_upgrade_error` , with an
empty default implementation. No implementation is required to
retain existing behaviour.
2020-06-30 17:10:53 +02:00
- Add `ProtocolsHandler::inject_address_change` and
`NetworkBehaviour::inject_address_change` to notify of a change in
the address of an existing connection.
2020-06-22 11:41:28 +02:00
# 0.19.1 [2020-06-18]
- Bugfix: Fix MultiHandler panicking when empty
([PR 1598 ](https://github.com/libp2p/rust-libp2p/pull/1598 )).