diff --git a/src/main.rs b/src/main.rs index c1ec5aa..788b41a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,7 +26,6 @@ const DEFAULT_CACHE: &str = "cache.nixos.org"; #[tokio::main(flavor = "multi_thread")] async fn main() -> io::Result<()> { - console_subscriber::init(); let host_name: String; let cache_url: String; @@ -76,10 +75,14 @@ async fn main() -> io::Result<()> { let binding = get_requisites(&host_name); - let tasks = binding + let lines = binding .lines() .map(|line| line.to_owned()) - .collect::>() + .collect::>(); + + let count = lines.len(); + + let tasks = lines .into_iter() .map(|hash| { let client = client.clone(); @@ -97,7 +100,7 @@ async fn main() -> io::Result<()> { .map(|result| result.unwrap()) .sum(); - println!("sum {:#?}", sum); + println!("sum {:#?}/{}", sum, count); Ok(()) } diff --git a/src/net.rs b/src/net.rs index bcfd06c..5a8e0c1 100644 --- a/src/net.rs +++ b/src/net.rs @@ -4,6 +4,8 @@ use async_recursion::async_recursion; use reqwest::Client; use tokio::time::sleep; +const MAX_SLIDE: u64 = 1000; + #[async_recursion] pub async fn nar_exists(client: Client, domain: &str, hash: &str, slide: u64) -> usize { let response = client @@ -19,9 +21,8 @@ pub async fn nar_exists(client: Client, domain: &str, hash: &str, slide: u64) -> // // Writng an actual sliding window seems kinda hard, // so we do this instead. - println!("blablabllb"); sleep(Duration::from_millis(slide)).await; - nar_exists(client, domain, hash, slide * 2).await + nar_exists(client, domain, hash, std::cmp::min(slide * 2, MAX_SLIDE)).await } } }