Skip to content

Commit

Permalink
fix(relay): use web_time Instant and SystemTime versions for wa…
Browse files Browse the repository at this point in the history
…sm support.

Resolves #5305.

Pull-Request: #5328.
  • Loading branch information
dariusc93 committed Apr 30, 2024
1 parent 6b270f6 commit e5c072c
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 2 additions & 0 deletions protocols/relay/CHANGELOG.md
Expand Up @@ -2,6 +2,8 @@

- Fix support for unlimited relay connection according to spec.
See [PR 5244](https://github.com/libp2p/rust-libp2p/pull/5244).
- use `web_time` `Instant` and `SystemTime` versions for wasm support.
See [PR 5328](https://github.com/libp2p/rust-libp2p/pull/5328).

## 0.17.1

Expand Down
2 changes: 1 addition & 1 deletion protocols/relay/Cargo.toml
Expand Up @@ -17,7 +17,6 @@ either = "1.11.0"
futures = { workspace = true }
futures-timer = "3"
futures-bounded = { workspace = true }
instant = "0.1.12"
libp2p-core = { workspace = true }
libp2p-swarm = { workspace = true }
libp2p-identity = { workspace = true }
Expand All @@ -28,6 +27,7 @@ static_assertions = "1"
thiserror = "1.0"
tracing = { workspace = true }
void = "1"
web-time = "1"

[dev-dependencies]
libp2p-identity = { workspace = true, features = ["rand"] }
Expand Down
2 changes: 1 addition & 1 deletion protocols/relay/src/behaviour.rs
Expand Up @@ -27,7 +27,6 @@ use crate::multiaddr_ext::MultiaddrExt;
use crate::proto;
use crate::protocol::{inbound_hop, outbound_stop};
use either::Either;
use instant::Instant;
use libp2p_core::multiaddr::Protocol;
use libp2p_core::{ConnectedPoint, Endpoint, Multiaddr};
use libp2p_identity::PeerId;
Expand All @@ -41,6 +40,7 @@ use std::num::NonZeroU32;
use std::ops::Add;
use std::task::{Context, Poll};
use std::time::Duration;
use web_time::Instant;

/// Configuration for the relay [`Behaviour`].
///
Expand Down
2 changes: 1 addition & 1 deletion protocols/relay/src/behaviour/handler.rs
Expand Up @@ -28,7 +28,6 @@ use futures::future::{BoxFuture, FutureExt, TryFutureExt};
use futures::io::AsyncWriteExt;
use futures::stream::{FuturesUnordered, StreamExt};
use futures_timer::Delay;
use instant::Instant;
use libp2p_core::upgrade::ReadyUpgrade;
use libp2p_core::{ConnectedPoint, Multiaddr};
use libp2p_identity::PeerId;
Expand All @@ -43,6 +42,7 @@ use std::collections::{HashMap, VecDeque};
use std::task::{Context, Poll};
use std::time::Duration;
use std::{fmt, io};
use web_time::Instant;

const MAX_CONCURRENT_STREAMS_PER_CONNECTION: usize = 10;
const STREAM_TIMEOUT: Duration = Duration::from_secs(60);
Expand Down
2 changes: 1 addition & 1 deletion protocols/relay/src/behaviour/rate_limiter.rs
Expand Up @@ -18,14 +18,14 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

use instant::Instant;
use libp2p_core::multiaddr::{Multiaddr, Protocol};
use libp2p_identity::PeerId;
use std::collections::{HashMap, VecDeque};
use std::hash::Hash;
use std::net::IpAddr;
use std::num::NonZeroU32;
use std::time::Duration;
use web_time::Instant;

/// Allows rate limiting access to some resource based on the [`PeerId`] and
/// [`Multiaddr`] of a remote peer.
Expand Down
3 changes: 2 additions & 1 deletion protocols/relay/src/protocol/inbound_hop.rs
Expand Up @@ -18,7 +18,8 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

use std::time::{Duration, SystemTime};
use std::time::Duration;
use web_time::SystemTime;

use asynchronous_codec::{Framed, FramedParts};
use bytes::Bytes;
Expand Down
3 changes: 2 additions & 1 deletion protocols/relay/src/protocol/outbound_hop.rs
Expand Up @@ -19,13 +19,14 @@
// DEALINGS IN THE SOFTWARE.

use std::io;
use std::time::{Duration, SystemTime};
use std::time::Duration;

use asynchronous_codec::{Framed, FramedParts};
use bytes::Bytes;
use futures::prelude::*;
use futures_timer::Delay;
use thiserror::Error;
use web_time::SystemTime;

use libp2p_core::Multiaddr;
use libp2p_identity::PeerId;
Expand Down

0 comments on commit e5c072c

Please sign in to comment.