Skip to content

Commit

Permalink
feat(ping): impose Sync bound to ping::Failure::Other
Browse files Browse the repository at this point in the history
Allow `ping::Event` to be shared between threads, instead of only sending between threads but no sharing.
This make it possible to send `ping::Event` through broadcast-style channels, like `tokio::sync::broadcast`.

Pull-Request: #5250.
  • Loading branch information
drHuangMHT authored Apr 5, 2024
1 parent fdddacc commit 47e19f7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 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 @@ -92,7 +92,7 @@ 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.0", path = "protocols/perf" }
libp2p-ping = { version = "0.44.0", path = "protocols/ping" }
libp2p-ping = { version = "0.44.1", path = "protocols/ping" }
libp2p-plaintext = { version = "0.41.0", path = "transports/plaintext" }
libp2p-pnet = { version = "0.24.0", path = "transports/pnet" }
libp2p-quic = { version = "0.10.2", path = "transports/quic" }
Expand Down
8 changes: 8 additions & 0 deletions protocols/ping/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.44.1 - unreleased

- Impose `Sync` on `ping::Failure::Other`.
`ping::Event` can now be shared between threads.
See [PR 5250]

[PR 5250]: https://github.com/libp2p/rust-libp2p/pull/5250

## 0.44.0


Expand Down
2 changes: 1 addition & 1 deletion protocols/ping/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-ping"
edition = "2021"
rust-version = { workspace = true }
description = "Ping protocol for libp2p"
version = "0.44.0"
version = "0.44.1"
authors = ["Parity Technologies <[email protected]>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
Expand Down
4 changes: 2 additions & 2 deletions protocols/ping/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ pub enum Failure {
Unsupported,
/// The ping failed for reasons other than a timeout.
Other {
error: Box<dyn std::error::Error + Send + 'static>,
error: Box<dyn std::error::Error + Send + Sync + 'static>,
},
}

impl Failure {
fn other(e: impl std::error::Error + Send + 'static) -> Self {
fn other(e: impl std::error::Error + Send + Sync + 'static) -> Self {
Self::Other { error: Box::new(e) }
}
}
Expand Down

0 comments on commit 47e19f7

Please sign in to comment.