Skip to content

Commit

Permalink
Depend on n0-future for task and time utils
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus23 committed Jan 24, 2025
1 parent b730b17 commit d6250d3
Show file tree
Hide file tree
Showing 17 changed files with 43 additions and 33 deletions.
17 changes: 9 additions & 8 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions iroh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ futures-sink = "0.3"
futures-util = "0.3"
iroh-base = { version = "0.31.0", default-features = false, features = ["key", "relay"], path = "../iroh-base" }
iroh-relay = { version = "0.31", path = "../iroh-relay", default-features = false }
n0-future = "0.0.1"
net-report = { package = "iroh-net-report", path = "../iroh-net-report", version = "0.31", default-features = false }
pin-project = "1"
pkarr = { version = "2", default-features = false, features = [
Expand Down
2 changes: 1 addition & 1 deletion iroh/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub mod staging {

/// Contains all timeouts that we use in `iroh`.
pub(crate) mod timeouts {
use iroh_relay::time::Duration;
use n0_future::time::Duration;

// Timeouts for net_report

Expand Down
6 changes: 4 additions & 2 deletions iroh/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ use futures_lite::stream::Boxed as BoxStream;
use futures_lite::stream::BoxedLocal as BoxStream;
use futures_lite::stream::StreamExt;
use iroh_base::{NodeAddr, NodeId, RelayUrl};
use iroh_relay::time::{self, Duration};
use net_report::task::{self, AbortOnDropHandle};
use n0_future::{
task::{self, AbortOnDropHandle},
time::{self, Duration},
};
use tokio::sync::oneshot;
use tracing::{debug, error_span, warn, Instrument};

Expand Down
6 changes: 4 additions & 2 deletions iroh/src/discovery/pkarr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ use futures_lite::stream::Boxed as BoxStream;
#[cfg(wasm_browser)]
use futures_lite::stream::BoxedLocal as BoxStream;
use iroh_base::{NodeId, RelayUrl, SecretKey};
use iroh_relay::time::{self, Duration, Instant};
use net_report::task::{self, AbortOnDropHandle};
use n0_future::{
task::{self, AbortOnDropHandle},
time::{self, Duration, Instant},
};
use pkarr::SignedPacket;
use tracing::{debug, error_span, info, warn, Instrument};
use url::Url;
Expand Down
2 changes: 1 addition & 1 deletion iroh/src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use anyhow::Result;
use futures_lite::{Future, StreamExt};
use hickory_resolver::{IntoName, Resolver, TokioResolver};
use iroh_base::{NodeAddr, NodeId};
use iroh_relay::time::{self, Duration};
use n0_future::time::{self, Duration};

use crate::node_info;

Expand Down
2 changes: 1 addition & 1 deletion iroh/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use std::{

use anyhow::{bail, Context, Result};
use iroh_base::{NodeAddr, NodeId, PublicKey, RelayUrl, SecretKey};
use iroh_relay::time::Duration;
use iroh_relay::RelayMap;
use n0_future::time::Duration;
use pin_project::pin_project;
use tracing::{debug, instrument, trace, warn};
use url::Url;
Expand Down
2 changes: 1 addition & 1 deletion iroh/src/endpoint/rtt_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use futures_buffered::MergeUnbounded;
use futures_lite::{Stream, StreamExt};
use iroh_base::NodeId;
use iroh_metrics::inc;
use net_report::task::{self, AbortOnDropHandle};
use n0_future::task::{self, AbortOnDropHandle};
use tokio::sync::mpsc;
use tracing::{debug, info_span, Instrument};

Expand Down
7 changes: 4 additions & 3 deletions iroh/src/magicsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ use futures_lite::{FutureExt, StreamExt};
use futures_util::task::AtomicWaker;
use iroh_base::{NodeAddr, NodeId, PublicKey, RelayUrl, SecretKey};
use iroh_metrics::{inc, inc_by};
use iroh_relay::time::{self, Duration, Instant};
use iroh_relay::{protos::stun, RelayMap};
use net_report::task;
use net_report::task::JoinSet;
use n0_future::{
task::{self, JoinSet},
time::{self, Duration, Instant},
};
#[cfg(not(wasm_browser))]
use netwatch::{interfaces, ip::LocalAddresses, netmon, UdpSocket};
use quinn::AsyncUdpSocket;
Expand Down
2 changes: 1 addition & 1 deletion iroh/src/magicsock/node_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{

use iroh_base::{NodeAddr, NodeId, PublicKey, RelayUrl};
use iroh_metrics::inc;
use iroh_relay::time::Instant;
use n0_future::time::Instant;
use serde::{Deserialize, Serialize};
use stun_rs::TransactionId;
use tracing::{debug, info, instrument, trace, warn};
Expand Down
2 changes: 1 addition & 1 deletion iroh/src/magicsock/node_map/best_addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::net::SocketAddr;

use iroh_relay::time::{Duration, Instant};
use n0_future::time::{Duration, Instant};
use tracing::{debug, info};

/// How long we trust a UDP address as the exclusive path (without using relay) without having heard a Pong reply.
Expand Down
6 changes: 4 additions & 2 deletions iroh/src/magicsock/node_map/node_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ use data_encoding::HEXLOWER;
use iroh_base::{NodeAddr, NodeId, PublicKey, RelayUrl};
use iroh_metrics::inc;
use iroh_relay::protos::stun;
use iroh_relay::time::{self, Duration, Instant};
use net_report::task::{self, AbortOnDropHandle};
use n0_future::{
task::{self, AbortOnDropHandle},
time::{self, Duration, Instant},
};
use serde::{Deserialize, Serialize};
use tokio::sync::mpsc;
use tracing::{debug, event, info, instrument, trace, warn, Level};
Expand Down
2 changes: 1 addition & 1 deletion iroh/src/magicsock/node_map/path_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{

use iroh_base::NodeId;
use iroh_relay::protos::stun;
use iroh_relay::time::{Duration, Instant};
use n0_future::time::{Duration, Instant};
use tracing::{debug, event, Level};

use super::{
Expand Down
2 changes: 1 addition & 1 deletion iroh/src/magicsock/node_map/udp_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! [`NodeState`]: super::node_state::NodeState
use std::{collections::BTreeMap, net::SocketAddr};

use iroh_relay::time::{Duration, Instant};
use n0_future::time::{Duration, Instant};
use rand::seq::IteratorRandom;
use tracing::warn;

Expand Down
11 changes: 6 additions & 5 deletions iroh/src/magicsock/relay_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ use futures_lite::StreamExt;
use futures_util::SinkExt;
use iroh_base::{NodeId, PublicKey, RelayUrl, SecretKey};
use iroh_metrics::{inc, inc_by};
use iroh_relay::time::{Duration, Instant};
use iroh_relay::{
self as relay,
client::{Client, ReceivedMessage, SendMessage},
time::{self, MissedTickBehavior},
PingTracker, MAX_PACKET_SIZE,
};
use net_report::task::JoinSet;
use n0_future::{
task::JoinSet,
time::{self, Duration, Instant, MissedTickBehavior},
};
use tokio::sync::{mpsc, oneshot};
use tokio_util::sync::CancellationToken;
use tracing::{debug, error, event, info_span, instrument, trace, warn, Instrument, Level};
Expand Down Expand Up @@ -427,10 +428,10 @@ impl ActiveRelayActor {
struct Sleeper;

impl backoff::future::Sleeper for Sleeper {
type Sleep = iroh_relay::time::Sleep;
type Sleep = time::Sleep;

fn sleep(&self, dur: Duration) -> Self::Sleep {
iroh_relay::time::sleep(dur)
time::sleep(dur)
}
}

Expand Down
4 changes: 2 additions & 2 deletions iroh/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl<T: Future> Future for MaybeFuture<T> {
mod tests {
use std::pin::pin;

use iroh_relay::time::Duration;
use n0_future::time::{self, Duration};

use super::*;

Expand All @@ -86,7 +86,7 @@ mod tests {
assert_eq!(res, "hello");

// Now poll again
let res = iroh_relay::time::timeout(Duration::from_millis(10), maybe_fut).await;
let res = time::timeout(Duration::from_millis(10), maybe_fut).await;
assert!(res.is_err());
}
}
2 changes: 1 addition & 1 deletion iroh/src/web_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
task::{Context, Poll},
};

use iroh_relay::time;
use n0_future::time;

#[derive(Debug, Clone)]
pub struct WebRuntime;
Expand Down

0 comments on commit d6250d3

Please sign in to comment.