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

fix(kad,mdns,misc): ensure instant is used instead of std::time #5391

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 4 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions misc/memory-connection-limits/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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


Expand Down
3 changes: 2 additions & 1 deletion misc/memory-connection-limits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion misc/memory-connection-limits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions protocols/kad/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion protocols/kad/src/kbucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions protocols/mdns/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
3 changes: 2 additions & 1 deletion protocols/mdns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <admin@parity.io>"]
license = "MIT"
Expand All @@ -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 }
Expand Down
3 changes: 2 additions & 1 deletion protocols/mdns/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion protocols/mdns/src/behaviour/iface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions protocols/mdns/src/behaviour/iface/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion protocols/mdns/src/behaviour/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
Loading