From 94f37daea0fbe36dab4f578c66e0c99ca99d732e Mon Sep 17 00:00:00 2001 From: Monius Date: Mon, 19 Aug 2024 15:15:49 +0800 Subject: [PATCH] v0.0.6 --- Cargo.toml | 2 +- src/client/process.rs | 113 +++++++++++++++++++++++------------------- 2 files changed, 63 insertions(+), 52 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8104140..961d74d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aw" -version = "0.0.5" +version = "0.0.6" edition = "2021" [dependencies] diff --git a/src/client/process.rs b/src/client/process.rs index 5b65f2d..a6f4a24 100644 --- a/src/client/process.rs +++ b/src/client/process.rs @@ -12,7 +12,7 @@ use super::geo; pub async fn batch_create(num: usize) -> Vec { let mp = MultiProgress::new(); - let create_style = ProgressStyle::with_template("[{elapsed_precise}] [{eta_precise}] {wide_bar:.cyan/green} {pos:>7}/{len:7}") + let _style = ProgressStyle::with_template("[{elapsed_precise}] [{eta_precise}] {wide_bar:.cyan/green} {pos:>7}/{len:7}") .unwrap() .tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ "); @@ -32,7 +32,7 @@ pub async fn batch_create(num: usize) -> Vec { _tasks.append(&mut tasks); let pb = mp.add(ProgressBar::new(_tasks.len() as u64)); - pb.set_style(create_style.clone()); + pb.set_style(_style.clone()); for task in _tasks { if let Ok(Ok(warp)) = task.await { @@ -45,30 +45,35 @@ pub async fn batch_create(num: usize) -> Vec { tokio::time::sleep(RETRY_DELAY).await; } } - - let _pb = mp.add(ProgressBar::new(tasks.len() as u64)); - _pb.set_style(create_style.clone()); - for task in tasks { - if let Ok(Ok(warp)) = task.await { - warps.push(warp); + if tasks.len() > 0{ + if tasks.len()>100{ + tokio::time::sleep(RETRY_DELAY).await; + } + let _pb = mp.add(ProgressBar::new(tasks.len() as u64)); + _pb.set_style(_style.clone()); + for task in tasks { + if let Ok(Ok(warp)) = task.await { + warps.push(warp); + } + _pb.inc(1); } - _pb.inc(1); + _pb.finish(); } - _pb.finish(); warps } pub async fn batch_seed(warp: Vec) -> Vec { let mp = MultiProgress::new(); - let seed_style = ProgressStyle::with_template("[{elapsed_precise}] [{eta_precise}] {wide_bar:.cyan/yellow} {pos:>7}/{len:7}") + let _style = ProgressStyle::with_template("[{elapsed_precise}] [{eta_precise}] {wide_bar:.cyan/yellow} {pos:>7}/{len:7}") .unwrap() .tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ "); - - let mut _warps = warp.clone(); - let pool = cipher::decode(_EPOOL); + + let epool = std::env::var("EPOOL").unwrap_or_else(|_| _EPOOL.to_string()); + let pool = cipher::decode(&epool); let seeds : Vec<_> = pool.split(" ").into_iter().collect(); let mut tasks = Vec::new(); let mut warps = Vec::new(); + let mut _warps = warp.clone(); for _ in 0..MAX_SEED { for seed in &seeds { @@ -88,7 +93,7 @@ pub async fn batch_seed(warp: Vec) -> Vec { _tasks.append(&mut tasks); let pb = mp.add(ProgressBar::new(_tasks.len() as u64)); - pb.set_style(seed_style.clone()); + pb.set_style(_style.clone()); for task in _tasks { if let Ok(Ok(warp)) = task.await { @@ -102,24 +107,26 @@ pub async fn batch_seed(warp: Vec) -> Vec { } } - let _pb = mp.add(ProgressBar::new(tasks.len() as u64)); - _pb.set_style(seed_style.clone()); - if tasks.len()>100{ - tokio::time::sleep(RETRY_DELAY).await; - } - for task in tasks { - if let Ok(Ok(warp)) = task.await { - warps.push(warp); + if tasks.len() > 0{ + if tasks.len()>100{ + tokio::time::sleep(RETRY_DELAY).await; + } + let _pb = mp.add(ProgressBar::new(tasks.len() as u64)); + _pb.set_style(_style.clone()); + for task in tasks { + if let Ok(Ok(warp)) = task.await { + warps.push(warp); + } + _pb.inc(1); } - _pb.inc(1); + _pb.finish(); } - _pb.finish(); warps } pub async fn batch_update(warp: Vec) -> Vec { let mp = MultiProgress::new(); - let update_style = ProgressStyle::with_template("[{elapsed_precise}] [{eta_precise}] {wide_bar:.cyan/blue} {pos:>7}/{len:7}") + let _style = ProgressStyle::with_template("[{elapsed_precise}] [{eta_precise}] {wide_bar:.cyan/blue} {pos:>7}/{len:7}") .unwrap() .tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ "); @@ -139,7 +146,7 @@ pub async fn batch_update(warp: Vec) -> Vec { _tasks.append(&mut tasks); let pb = mp.add(ProgressBar::new(_tasks.len() as u64)); - pb.set_style(update_style.clone()); + pb.set_style(_style.clone()); for task in _tasks { if let Ok(Ok(warp)) = task.await { @@ -152,25 +159,27 @@ pub async fn batch_update(warp: Vec) -> Vec { } } - let _pb = mp.add(ProgressBar::new(tasks.len() as u64)); - _pb.set_style(update_style.clone()); - if tasks.len()>100{ - tokio::time::sleep(RETRY_DELAY).await; - } - for task in tasks { - if let Ok(Ok(warp)) = task.await { - warps.push(warp); + if tasks.len() > 0{ + if tasks.len()>100{ + tokio::time::sleep(RETRY_DELAY).await; } - _pb.inc(1); + let _pb = mp.add(ProgressBar::new(tasks.len() as u64)); + _pb.set_style(_style.clone()); + for task in tasks { + if let Ok(Ok(warp)) = task.await { + warps.push(warp); + } + _pb.inc(1); + } + _pb.finish(); } - _pb.finish(); warps } pub async fn batch_delete(warp: Vec) -> Vec { let mp = MultiProgress::new(); - let delete_style = ProgressStyle::with_template("[{elapsed_precise}] [{eta_precise}] {wide_bar:.cyan/red} {pos:>7}/{len:7}") + let _style = ProgressStyle::with_template("[{elapsed_precise}] [{eta_precise}] {wide_bar:.cyan/red} {pos:>7}/{len:7}") .unwrap() .tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ "); @@ -189,7 +198,7 @@ pub async fn batch_delete(warp: Vec) -> Vec { _tasks.append(&mut tasks); let pb = mp.add(ProgressBar::new(_tasks.len() as u64)); - pb.set_style(delete_style.clone()); + pb.set_style(_style.clone()); for task in _tasks { if let Ok(Ok(warp)) = task.await { @@ -202,25 +211,27 @@ pub async fn batch_delete(warp: Vec) -> Vec { } } - let _pb = mp.add(ProgressBar::new(tasks.len() as u64)); - _pb.set_style(delete_style.clone()); - if tasks.len()>100{ - tokio::time::sleep(RETRY_DELAY).await; - } - for task in tasks { - if let Ok(Ok(warp)) = task.await { - warps.push(warp); + if tasks.len() > 0{ + if tasks.len()>100{ + tokio::time::sleep(RETRY_DELAY).await; + } + let _pb = mp.add(ProgressBar::new(tasks.len() as u64)); + _pb.set_style(_style.clone()); + for task in tasks { + if let Ok(Ok(warp)) = task.await { + warps.push(warp); + } + _pb.inc(1); } - _pb.inc(1); + _pb.finish(); } - _pb.finish(); warps } pub async fn batch_info(warp: Vec){ let mp = MultiProgress::new(); - let info_style = ProgressStyle::with_template("[{elapsed_precise}] [{eta_precise}] {wide_bar:.green/red} {pos:>7}/{len:7}") + let _style = ProgressStyle::with_template("[{elapsed_precise}] [{eta_precise}] {wide_bar:.green/red} {pos:>7}/{len:7}") .unwrap() .tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈ "); @@ -234,7 +245,7 @@ pub async fn batch_info(warp: Vec){ } let _pb = mp.add(ProgressBar::new(tasks.len() as u64)); - _pb.set_style(info_style.clone()); + _pb.set_style(_style.clone()); if tasks.len()>100{ tokio::time::sleep(RETRY_DELAY).await;