diff --git a/Cargo.lock b/Cargo.lock index a054df9fb35..1fc86a6052c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2949,7 +2949,7 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.45.1" +version = "0.45.2" dependencies = [ "async-io 2.3.2", "async-std", @@ -2957,6 +2957,7 @@ dependencies = [ "futures", "hickory-proto", "if-watch", + "instant", "libp2p-core", "libp2p-identity", "libp2p-noise", @@ -2975,9 +2976,10 @@ dependencies = [ [[package]] name = "libp2p-memory-connection-limits" -version = "0.2.0" +version = "0.2.1" dependencies = [ "async-std", + "instant", "libp2p-core", "libp2p-identify", "libp2p-identity", diff --git a/misc/memory-connection-limits/CHANGELOG.md b/misc/memory-connection-limits/CHANGELOG.md index fc598872d50..eb350403588 100644 --- a/misc/memory-connection-limits/CHANGELOG.md +++ b/misc/memory-connection-limits/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.1 -- unreleased + +- Replace usage of `std::time` with `instant` crate for wasm compatibility. + See [PR 5391](https://github.com/libp2p/rust-libp2p/pull/5391) + ## 0.2.0 diff --git a/misc/memory-connection-limits/Cargo.toml b/misc/memory-connection-limits/Cargo.toml index 5f8d9b91613..53f055175e1 100644 --- a/misc/memory-connection-limits/Cargo.toml +++ b/misc/memory-connection-limits/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-memory-connection-limits" edition = "2021" rust-version = { workspace = true } description = "Memory usage based connection limits for libp2p." -version = "0.2.0" +version = "0.2.1" license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" keywords = ["peer-to-peer", "libp2p", "networking"] @@ -14,6 +14,7 @@ memory-stats = { version = "1", features = ["always_use_statm"] } libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true, features = ["peerid"] } +instant = "0.1.12" sysinfo = "0.29" tracing = { workspace = true } void = "1" diff --git a/misc/memory-connection-limits/src/lib.rs b/misc/memory-connection-limits/src/lib.rs index ac911654979..839ea529dea 100644 --- a/misc/memory-connection-limits/src/lib.rs +++ b/misc/memory-connection-limits/src/lib.rs @@ -18,6 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +use instant::{Duration, Instant}; use libp2p_core::{Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::{ @@ -29,7 +30,6 @@ use void::Void; use std::{ fmt, task::{Context, Poll}, - time::{Duration, Instant}, }; /// A [`NetworkBehaviour`] that enforces a set of memory usage based limits. diff --git a/protocols/kad/CHANGELOG.md b/protocols/kad/CHANGELOG.md index bd0c9857cb5..c16ef632c2f 100644 --- a/protocols/kad/CHANGELOG.md +++ b/protocols/kad/CHANGELOG.md @@ -1,5 +1,7 @@ ## 0.46.0 -- unreleased +- Replace usage of `std::time` with `instant` crate for wasm compatibility. + See [PR 5391](https://github.com/libp2p/rust-libp2p/pull/5391) - Changed `FIND_NODE` response: now includes a list of closest peers when querying the recipient peer ID. Previously, this request yielded an empty response. See [PR 5270](https://github.com/libp2p/rust-libp2p/pull/5270) - Update to DHT republish interval and expiration time defaults to 22h and 48h respectively, rationale in [libp2p/specs#451](https://github.com/libp2p/specs/pull/451) diff --git a/protocols/kad/src/kbucket.rs b/protocols/kad/src/kbucket.rs index 6eb2e42909a..2cbf38dad66 100644 --- a/protocols/kad/src/kbucket.rs +++ b/protocols/kad/src/kbucket.rs @@ -77,8 +77,8 @@ pub use entry::*; use arrayvec::ArrayVec; use bucket::KBucket; +use instant::{Duration, Instant}; use std::collections::VecDeque; -use std::time::{Duration, Instant}; /// Maximum number of k-buckets. const NUM_BUCKETS: usize = 256; diff --git a/protocols/mdns/CHANGELOG.md b/protocols/mdns/CHANGELOG.md index cfd02232b07..ec0bd3673ea 100644 --- a/protocols/mdns/CHANGELOG.md +++ b/protocols/mdns/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.45.2 -- unreleased + +- Replace usage of `std::time` with `instant` crate for wasm compatibility. + See [PR 5391](https://github.com/libp2p/rust-libp2p/pull/5391) + ## 0.45.1 - Ensure `Multiaddr` handled and returned by `Behaviour` are `/p2p` terminated. diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index 061651c07d4..ee886598a11 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -2,7 +2,7 @@ name = "libp2p-mdns" edition = "2021" rust-version = { workspace = true } -version = "0.45.1" +version = "0.45.2" description = "Implementation of the libp2p mDNS discovery method" authors = ["Parity Technologies "] license = "MIT" @@ -16,6 +16,7 @@ async-io = { version = "2.3.2", optional = true } data-encoding = "2.6.0" futures = { workspace = true } if-watch = "3.2.0" +instant = "0.1.12" libp2p-core = { workspace = true } libp2p-swarm = { workspace = true } libp2p-identity = { workspace = true } diff --git a/protocols/mdns/src/behaviour.rs b/protocols/mdns/src/behaviour.rs index 4e3533f26ab..a6bf9333307 100644 --- a/protocols/mdns/src/behaviour.rs +++ b/protocols/mdns/src/behaviour.rs @@ -28,6 +28,7 @@ use crate::Config; use futures::channel::mpsc; use futures::{Stream, StreamExt}; use if_watch::IfEvent; +use instant::Instant; use libp2p_core::{Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::behaviour::FromSwarm; @@ -39,7 +40,7 @@ use smallvec::SmallVec; use std::collections::hash_map::{Entry, HashMap}; use std::future::Future; use std::sync::{Arc, RwLock}; -use std::{cmp, fmt, io, net::IpAddr, pin::Pin, task::Context, task::Poll, time::Instant}; +use std::{cmp, fmt, io, net::IpAddr, pin::Pin, task::Context, task::Poll}; /// An abstraction to allow for compatibility with various async runtimes. pub trait Provider: 'static { diff --git a/protocols/mdns/src/behaviour/iface.rs b/protocols/mdns/src/behaviour/iface.rs index 9302065cde2..f09348d61ab 100644 --- a/protocols/mdns/src/behaviour/iface.rs +++ b/protocols/mdns/src/behaviour/iface.rs @@ -27,6 +27,7 @@ use crate::behaviour::{socket::AsyncSocket, timer::Builder}; use crate::Config; use futures::channel::mpsc; use futures::{SinkExt, StreamExt}; +use instant::{Duration, Instant}; use libp2p_core::Multiaddr; use libp2p_identity::PeerId; use libp2p_swarm::ListenAddresses; @@ -39,7 +40,6 @@ use std::{ net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, UdpSocket}, pin::Pin, task::{Context, Poll}, - time::{Duration, Instant}, }; /// Initial interval for starting probe diff --git a/protocols/mdns/src/behaviour/iface/query.rs b/protocols/mdns/src/behaviour/iface/query.rs index eeb699fca6b..5912ab09cb8 100644 --- a/protocols/mdns/src/behaviour/iface/query.rs +++ b/protocols/mdns/src/behaviour/iface/query.rs @@ -24,13 +24,13 @@ use hickory_proto::{ op::Message, rr::{Name, RData}, }; +use instant::{Duration, Instant}; use libp2p_core::{ address_translation, multiaddr::{Multiaddr, Protocol}, }; use libp2p_identity::PeerId; -use std::time::Instant; -use std::{fmt, net::SocketAddr, str, time::Duration}; +use std::{fmt, net::SocketAddr, str}; /// A valid mDNS packet received by the service. #[derive(Debug)] diff --git a/protocols/mdns/src/behaviour/timer.rs b/protocols/mdns/src/behaviour/timer.rs index 5e284654676..17b07ddae7a 100644 --- a/protocols/mdns/src/behaviour/timer.rs +++ b/protocols/mdns/src/behaviour/timer.rs @@ -18,7 +18,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use std::time::{Duration, Instant}; +use instant::{Duration, Instant}; /// Simple wrapper for the different type of timers #[derive(Debug)]