feat: add count
Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
parent
aaa6d05b92
commit
188fca648a
2 changed files with 10 additions and 6 deletions
11
src/main.rs
11
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::<Vec<_>>()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
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(())
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue