diff --git a/protocols/gossipsub/src/peer_score.rs b/protocols/gossipsub/src/peer_score.rs index 9e78ff69d4b..847d9117e54 100644 --- a/protocols/gossipsub/src/peer_score.rs +++ b/protocols/gossipsub/src/peer_score.rs @@ -27,7 +27,8 @@ use libp2p_core::PeerId; use log::{debug, trace, warn}; use std::collections::{hash_map, HashMap, HashSet}; use std::net::IpAddr; -use std::time::{Duration, Instant}; +use std::time::Duration; +use wasm_timer::Instant; mod params; use crate::error::ValidationError; diff --git a/protocols/gossipsub/src/time_cache.rs b/protocols/gossipsub/src/time_cache.rs index 90300e77ea3..0597733b008 100644 --- a/protocols/gossipsub/src/time_cache.rs +++ b/protocols/gossipsub/src/time_cache.rs @@ -26,7 +26,9 @@ use std::collections::hash_map::{ Entry::{Occupied, Vacant}, }; use std::collections::VecDeque; -use std::time::{Duration, Instant}; +use std::time::Duration; +use wasm_timer::Instant; + struct ExpiringElement { /// The element that expires diff --git a/protocols/kad/src/kbucket.rs b/protocols/kad/src/kbucket.rs index a77d39f0ee7..bfc0d836df6 100644 --- a/protocols/kad/src/kbucket.rs +++ b/protocols/kad/src/kbucket.rs @@ -77,7 +77,8 @@ pub use entry::*; use arrayvec::{self, ArrayVec}; use bucket::KBucket; use std::collections::VecDeque; -use std::time::{Duration, Instant}; +use std::time::Duration; +use wasm_timer::Instant; /// Maximum number of k-buckets. const NUM_BUCKETS: usize = 256; diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index d4cbed718b8..99998f2e15a 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -23,6 +23,7 @@ rand = "0.8.3" smallvec = "1.6.1" socket2 = { version = "0.4.0", features = ["all"] } void = "1.0.2" +wasm-timer = "0.2.4" [dev-dependencies] async-std = "1.9.0" diff --git a/protocols/mdns/src/behaviour.rs b/protocols/mdns/src/behaviour.rs index 95513eda49c..8ac394fe725 100644 --- a/protocols/mdns/src/behaviour.rs +++ b/protocols/mdns/src/behaviour.rs @@ -42,8 +42,9 @@ use std::{ pin::Pin, task::Context, task::Poll, - time::{Duration, Instant}, + time::Duration, }; +use wasm_timer::Instant; lazy_static! { static ref IPV4_MDNS_MULTICAST_ADDRESS: SocketAddr =