Skip to content

Commit

Permalink
feat: Add ConnectionError to FromSwarm::ConnectionClosed
Browse files Browse the repository at this point in the history
Resolves libp2p#5484.

Pull-Request: libp2p#5485.
  • Loading branch information
dariusc93 authored Jul 9, 2024
1 parent 4e4b594 commit 02fa7c8
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ libp2p-core = { version = "0.41.3", path = "core" }
libp2p-dcutr = { version = "0.11.1", path = "protocols/dcutr" }
libp2p-dns = { version = "0.41.1", path = "transports/dns" }
libp2p-floodsub = { version = "0.44.0", path = "protocols/floodsub" }
libp2p-gossipsub = { version = "0.46.2", path = "protocols/gossipsub" }
libp2p-gossipsub = { version = "0.47.0", path = "protocols/gossipsub" }
libp2p-identify = { version = "0.45.0", path = "protocols/identify" }
libp2p-identity = { version = "0.2.9" }
libp2p-kad = { version = "0.46.0", path = "protocols/kad" }
Expand All @@ -92,7 +92,7 @@ libp2p-metrics = { version = "0.14.2", path = "misc/metrics" }
libp2p-mplex = { version = "0.41.0", path = "muxers/mplex" }
libp2p-muxer-test-harness = { path = "muxers/test-harness" }
libp2p-noise = { version = "0.44.0", path = "transports/noise" }
libp2p-perf = { version = "0.3.1", path = "protocols/perf" }
libp2p-perf = { version = "0.4.0", path = "protocols/perf" }
libp2p-ping = { version = "0.44.2", path = "protocols/ping" }
libp2p-plaintext = { version = "0.41.0", path = "transports/plaintext" }
libp2p-pnet = { version = "0.24.0", path = "transports/pnet" }
Expand Down
4 changes: 4 additions & 0 deletions protocols/gossipsub/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.47.0
- Add ConnectionError to FromSwarm::ConnectionClosed.
See [PR 5485](https://github.com/libp2p/rust-libp2p/pull/5485).

## 0.46.2
- Use `web-time` instead of `instant`.
See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347).
Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-gossipsub"
edition = "2021"
rust-version = { workspace = true }
description = "Gossipsub protocol for libp2p"
version = "0.46.2"
version = "0.47.0"
authors = ["Age Manning <Age@AgeManning.com>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
1 change: 1 addition & 0 deletions protocols/gossipsub/src/behaviour/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ where
connection_id,
endpoint: &fake_endpoint,
remaining_established: active_connections,
cause: None,
}));
}
}
Expand Down
4 changes: 4 additions & 0 deletions protocols/perf/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.0
- Add ConnectionError to FromSwarm::ConnectionClosed.
See [PR 5485](https://github.com/libp2p/rust-libp2p/pull/5485).

## 0.3.1
- Use `web-time` instead of `instant`.
See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347).
Expand Down
2 changes: 1 addition & 1 deletion protocols/perf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-perf"
edition = "2021"
rust-version = { workspace = true }
description = "libp2p perf protocol implementation"
version = "0.3.1"
version = "0.4.0"
authors = ["Max Inden <mail@max-inden.de>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
1 change: 1 addition & 0 deletions protocols/perf/src/client/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ impl NetworkBehaviour for Behaviour {
connection_id: _,
endpoint: _,
remaining_established,
..
}) => {
if remaining_established == 0 {
assert!(self.connected.remove(&peer_id));
Expand Down
2 changes: 2 additions & 0 deletions swarm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
See [PR 5347](https://github.com/libp2p/rust-libp2p/pull/5347).
- Add `#[track_caller]` on all `spawn` wrappers.
See [PR 5465](https://github.com/libp2p/rust-libp2p/pull/5465).
- Add ConnectionError to FromSwarm::ConnectionClosed.
See [PR 5485](https://github.com/libp2p/rust-libp2p/pull/5485).

## 0.44.2

Expand Down
5 changes: 3 additions & 2 deletions swarm/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ use crate::connection::ConnectionId;
use crate::dial_opts::DialOpts;
use crate::listen_opts::ListenOpts;
use crate::{
ConnectionDenied, ConnectionHandler, DialError, ListenError, THandler, THandlerInEvent,
THandlerOutEvent,
ConnectionDenied, ConnectionError, ConnectionHandler, DialError, ListenError, THandler,
THandlerInEvent, THandlerOutEvent,
};
use libp2p_core::{transport::ListenerId, ConnectedPoint, Endpoint, Multiaddr};
use libp2p_identity::PeerId;
Expand Down Expand Up @@ -481,6 +481,7 @@ pub struct ConnectionClosed<'a> {
pub peer_id: PeerId,
pub connection_id: ConnectionId,
pub endpoint: &'a ConnectedPoint,
pub cause: Option<&'a ConnectionError>,
pub remaining_established: usize,
}

Expand Down
1 change: 1 addition & 0 deletions swarm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,7 @@ where
peer_id,
connection_id: id,
endpoint: &endpoint,
cause: error.as_ref(),
remaining_established: num_established as usize,
}));
self.pending_swarm_events
Expand Down
2 changes: 2 additions & 0 deletions swarm/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ where
connection_id,
endpoint,
remaining_established,
cause,
}: ConnectionClosed,
) {
let mut other_closed_connections = self
Expand Down Expand Up @@ -350,6 +351,7 @@ where
connection_id,
endpoint,
remaining_established,
cause,
}));
}
}
Expand Down

0 comments on commit 02fa7c8

Please sign in to comment.