Skip to content

Commit 660fadb

Browse files
authored
chore(gossipsub): include in libp2p meta crate when compiling for wasm
Since #3973, gossipsub now fully supports wasm targets. It functions properly when added as a dependency on its own. However, when trying to use it under libp2p by activating a feature, it's not possible and the compiler will raise an error like `unresolved import libp2p::gossipsub`. This pull request enables the use of gossipsub for wasm targets when it's activated as a feature of the libp2p dependency. Pull-Request: #4217.
1 parent 1acf4a5 commit 660fadb

File tree

9 files changed

+24
-18
lines changed

9 files changed

+24
-18
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ libp2p-identify = { version = "0.43.0", path = "protocols/identify" }
7575
libp2p-identity = { version = "0.2.1" }
7676
libp2p-kad = { version = "0.44.2", path = "protocols/kad" }
7777
libp2p-mdns = { version = "0.44.0", path = "protocols/mdns" }
78-
libp2p-metrics = { version = "0.13.0", path = "misc/metrics" }
78+
libp2p-metrics = { version = "0.13.1", path = "misc/metrics" }
7979
libp2p-mplex = { version = "0.40.0", path = "muxers/mplex" }
8080
libp2p-muxer-test-harness = { path = "muxers/test-harness" }
8181
libp2p-noise = { version = "0.43.0", path = "transports/noise" }

libp2p/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.52.2 - unreleased
2+
3+
- Include gossipsub when compiling for wasm.
4+
See [PR 4217].
5+
6+
[PR 4217]: https://github.com/libp2p/rust-libp2p/pull/4217
7+
18
## 0.52.1
29

310
- Add `libp2p-webtransport-websys` providing WebTransport for WASM environments.

libp2p/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "libp2p"
33
edition = "2021"
44
rust-version = "1.65.0"
55
description = "Peer-to-peer networking library"
6-
version = "0.52.1"
6+
version = "0.52.2"
77
authors = ["Parity Technologies <[email protected]>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"

libp2p/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ pub use libp2p_dns as dns;
6565
#[doc(inline)]
6666
pub use libp2p_floodsub as floodsub;
6767
#[cfg(feature = "gossipsub")]
68-
#[cfg(not(target_os = "unknown"))]
6968
#[doc(inline)]
7069
pub use libp2p_gossipsub as gossipsub;
7170
#[cfg(feature = "identify")]

misc/metrics/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.13.1 - unreleased
2+
3+
- Enable gossipsub related data-type fields when compiling for wasm.
4+
See [PR 4217].
5+
6+
[PR 4217]: https://github.com/libp2p/rust-libp2p/pull/4217
7+
18
## 0.13.0
29

310
- Previously `libp2p-metrics::identify` would increase a counter / gauge / histogram on each

misc/metrics/Cargo.toml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,38 @@ name = "libp2p-metrics"
33
edition = "2021"
44
rust-version = "1.65.0"
55
description = "Metrics for libp2p"
6-
version = "0.13.0"
6+
version = "0.13.1"
77
authors = ["Max Inden <[email protected]>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"
1010
keywords = ["peer-to-peer", "libp2p", "networking"]
1111
categories = ["network-programming", "asynchronous"]
1212

1313
[features]
14+
dcutr = ["libp2p-dcutr"]
1415
gossipsub = ["libp2p-gossipsub"]
1516
identify = ["libp2p-identify"]
1617
kad = ["libp2p-kad"]
1718
ping = ["libp2p-ping"]
1819
relay = ["libp2p-relay"]
19-
dcutr = ["libp2p-dcutr"]
2020

2121
[dependencies]
2222
instant = "0.1.12"
2323
libp2p-core = { workspace = true }
2424
libp2p-dcutr = { workspace = true, optional = true }
25+
libp2p-gossipsub = { workspace = true, optional = true }
2526
libp2p-identify = { workspace = true, optional = true }
27+
libp2p-identity = { workspace = true }
2628
libp2p-kad = { workspace = true, optional = true }
2729
libp2p-ping = { workspace = true, optional = true }
2830
libp2p-relay = { workspace = true, optional = true }
2931
libp2p-swarm = { workspace = true }
30-
libp2p-identity = { workspace = true }
31-
prometheus-client = { version = "0.21.2"}
3232
once_cell = "1.18.0"
33-
34-
[target.'cfg(not(target_os = "unknown"))'.dependencies]
35-
libp2p-gossipsub = { workspace = true, optional = true }
33+
prometheus-client = { version = "0.21.2"}
3634

3735
# Passing arguments to the docsrs builder in order to properly document cfg's.
3836
# More information: https://docs.rs/about/builds#cross-compiling
3937
[package.metadata.docs.rs]
4038
all-features = true
41-
rustdoc-args = ["--cfg", "docsrs"]
4239
rustc-args = ["--cfg", "docsrs"]
40+
rustdoc-args = ["--cfg", "docsrs"]

misc/metrics/src/identify.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ const ALLOWED_PROTOCOLS: &[StreamProtocol] = &[
6464
#[cfg(feature = "dcutr")]
6565
libp2p_dcutr::PROTOCOL_NAME,
6666
// #[cfg(feature = "gossipsub")]
67-
// #[cfg(not(target_os = "unknown"))]
6867
// TODO: Add Gossipsub protocol name
6968
libp2p_identify::PROTOCOL_NAME,
7069
libp2p_identify::PUSH_PROTOCOL_NAME,

misc/metrics/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#[cfg(feature = "dcutr")]
3131
mod dcutr;
3232
#[cfg(feature = "gossipsub")]
33-
#[cfg(not(target_os = "unknown"))]
3433
mod gossipsub;
3534
#[cfg(feature = "identify")]
3635
mod identify;
@@ -50,7 +49,6 @@ pub struct Metrics {
5049
#[cfg(feature = "dcutr")]
5150
dcutr: dcutr::Metrics,
5251
#[cfg(feature = "gossipsub")]
53-
#[cfg(not(target_os = "unknown"))]
5452
gossipsub: gossipsub::Metrics,
5553
#[cfg(feature = "identify")]
5654
identify: identify::Metrics,
@@ -78,7 +76,6 @@ impl Metrics {
7876
#[cfg(feature = "dcutr")]
7977
dcutr: dcutr::Metrics::new(sub_registry),
8078
#[cfg(feature = "gossipsub")]
81-
#[cfg(not(target_os = "unknown"))]
8279
gossipsub: gossipsub::Metrics::new(sub_registry),
8380
#[cfg(feature = "identify")]
8481
identify: identify::Metrics::new(sub_registry),
@@ -107,7 +104,6 @@ impl Recorder<libp2p_dcutr::Event> for Metrics {
107104
}
108105

109106
#[cfg(feature = "gossipsub")]
110-
#[cfg(not(target_os = "unknown"))]
111107
impl Recorder<libp2p_gossipsub::Event> for Metrics {
112108
fn record(&self, event: &libp2p_gossipsub::Event) {
113109
self.gossipsub.record(event)

0 commit comments

Comments
 (0)