Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gossipsub): allow compiling for WASM #3973

Merged
merged 10 commits into from
May 25, 2023
74 changes: 23 additions & 51 deletions 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 core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ either = "1.5"
fnv = "1.0"
futures = { version = "0.3.28", features = ["executor", "thread-pool"] }
futures-timer = "3"
instant = "0.1.11"
instant = "0.1.12"
libp2p-identity = { workspace = true, features = ["peerid", "ed25519"] }
log = "0.4"
multiaddr = { version = "0.17.1" }
Expand Down
8 changes: 3 additions & 5 deletions libp2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ tcp = ["dep:libp2p-tcp"]
tls = ["dep:libp2p-tls"]
tokio = ["libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio", "libp2p-quic?/tokio", "libp2p-webrtc?/tokio"]
uds = ["dep:libp2p-uds"]
wasm-bindgen = ["futures-timer/wasm-bindgen", "instant/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen"]
wasm-bindgen = ["futures-timer/wasm-bindgen", "instant/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen", "libp2p-gossipsub?/wasm-bindgen"]
wasm-ext = ["dep:libp2p-wasm-ext"]
wasm-ext-websocket = ["wasm-ext", "libp2p-wasm-ext?/websocket"]
webrtc = ["dep:libp2p-webrtc", "libp2p-webrtc?/pem"]
Expand All @@ -92,14 +92,15 @@ bytes = "1"
futures = "0.3.26"
futures-timer = "3.0.2" # Explicit dependency to be used in `wasm-bindgen` feature
getrandom = "0.2.3" # Explicit dependency to be used in `wasm-bindgen` feature
instant = "0.1.11" # Explicit dependency to be used in `wasm-bindgen` feature
instant = "0.1.12" # Explicit dependency to be used in `wasm-bindgen` feature

libp2p-allow-block-list = { workspace = true }
libp2p-autonat = { workspace = true, optional = true }
libp2p-connection-limits = { workspace = true }
libp2p-core = { workspace = true }
libp2p-dcutr = { workspace = true, optional = true }
libp2p-floodsub = { workspace = true, optional = true }
libp2p-gossipsub = { workspace = true, optional = true }
libp2p-identify = { workspace = true, optional = true }
libp2p-identity = { workspace = true }
libp2p-kad = { workspace = true, optional = true }
Expand Down Expand Up @@ -130,9 +131,6 @@ libp2p-uds = { workspace = true, optional = true }
libp2p-webrtc = { workspace = true, optional = true }
libp2p-websocket = { workspace = true, optional = true }

[target.'cfg(not(target_os = "unknown"))'.dependencies]
libp2p-gossipsub = { workspace = true, optional = true }

[dev-dependencies]
async-std = { version = "1.6.2", features = ["attributes"] }
async-trait = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion misc/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ relay = ["libp2p-relay"]
dcutr = ["libp2p-dcutr"]

[dependencies]
instant = "0.1.11"
instant = "0.1.12"
libp2p-core = { workspace = true }
libp2p-dcutr = { workspace = true, optional = true }
libp2p-identify = { workspace = true, optional = true }
Expand Down
2 changes: 1 addition & 1 deletion protocols/dcutr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ asynchronous-codec = "0.6"
either = "1.6.0"
futures = "0.3.28"
futures-timer = "3.0"
instant = "0.1.11"
instant = "0.1.12"
libp2p-core = { workspace = true }
libp2p-swarm = { workspace = true }
libp2p-identity = { workspace = true }
Expand Down
33 changes: 19 additions & 14 deletions protocols/gossipsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,35 @@ repository = "https://github.com/libp2p/rust-libp2p"
keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]

[features]
wasm-bindgen = ["getrandom/js", "instant/wasm-bindgen"]
thomaseizinger marked this conversation as resolved.
Show resolved Hide resolved

[dependencies]
either = "1.5"
libp2p-swarm = { workspace = true }
libp2p-core = { workspace = true }
libp2p-identity = { workspace = true }
bytes = "1.4"
asynchronous-codec = "0.6"
base64 = "0.21.0"
byteorder = "1.3.4"
bytes = "1.4"
either = "1.5"
fnv = "1.0.7"
futures = "0.3.28"
rand = "0.8"
asynchronous-codec = "0.6"
unsigned-varint = { version = "0.7.0", features = ["asynchronous_codec"] }
futures-ticker = "0.0.2"
getrandom = "0.2.9"
hex_fmt = "0.3.0"
instant = "0.1.12"
libp2p-core = { workspace = true }
libp2p-identity = { workspace = true }
libp2p-swarm = { workspace = true }
log = "0.4.11"
sha2 = "0.10.0"
base64 = "0.21.0"
smallvec = "1.6.1"
quick-protobuf = "0.8"
quick-protobuf-codec = { workspace = true }
hex_fmt = "0.3.0"
rand = "0.8"
regex = "1.8.1"
serde = { version = "1", optional = true, features = ["derive"] }
wasm-timer = "0.2.5"
instant = "0.1.11"
sha2 = "0.10.0"
smallvec = "1.6.1"
unsigned-varint = { version = "0.7.0", features = ["asynchronous_codec"] }
void = "1.0.2"

# Metrics dependencies
prometheus-client = "0.21.0"

Expand Down
2 changes: 1 addition & 1 deletion protocols/gossipsub/src/backoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

//! Data structure for efficiently storing known back-off's when pruning peers.
use crate::topic::TopicHash;
use instant::Instant;
use libp2p_identity::PeerId;
use std::collections::{
hash_map::{Entry, HashMap},
HashSet,
};
use std::time::Duration;
use wasm_timer::Instant;

#[derive(Copy, Clone)]
struct HeartbeatIndex(usize);
Expand Down