Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tweak dependencies for wasm32 compilation.
For wasm32 we need to enable unstable features to
make `task::Builder::local` available.
  • Loading branch information
Roman S. Borschel committed Aug 11, 2020
commit c7ff520a4cd3be1f0f3627cdb0161baf15c94c36
9 changes: 7 additions & 2 deletions client/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ targets = ["x86_64-unknown-linux-gnu"]
prost-build = "0.6.1"

[dependencies]
async-std = "1.6.2"
bitflags = "1.2.0"
bs58 = "0.3.1"
bytes = "0.5.0"
Expand All @@ -27,7 +26,7 @@ erased-serde = "0.3.9"
fnv = "1.0.6"
fork-tree = { version = "2.0.0-rc5", path = "../../utils/fork-tree" }
futures = "0.3.4"
futures-timer = "3.0.1"
futures-timer = "3.0.2"
futures_codec = "0.4.0"
hex = "0.4.0"
ip_network = "0.3.4"
Expand Down Expand Up @@ -61,6 +60,12 @@ void = "1.0.2"
wasm-timer = "0.2"
zeroize = "1.0.0"

[target.'cfg(target_arch="wasm32")'.dependencies]
async-std = { version = "1.6.2", features = ["futures-timer", "unstable"] }

[target.'cfg(not(target_arch="wasm32"))'.dependencies]
async-std = { version = "1.6.2", features = ["futures-timer"] }

[dependencies.libp2p]
version = "0.23.0"
default-features = false
Expand Down
17 changes: 15 additions & 2 deletions client/network/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,25 @@ impl BandwidthMonitor {
output: monitor.clone(),
};

let _handle = task::Builder::new()
Self::spawn(task);

monitor
}

#[cfg(not(target_arch = "wasm32"))]
fn spawn(task: BandwidthTask) {
task::Builder::new()
.name("network-bandwidth".to_string())
.spawn(task.run())
.expect("Failed to spawn network-bandwidth task.");
}

monitor
#[cfg(target_arch = "wasm32")]
fn spawn(task: BandwidthTask) {
task::Builder::new()
.name("network-bandwidth".to_string())
.local(task.run())
.expect("Failed to spawn network-bandwidth task.");
}
}

Expand Down