Skip to content

Commit 5772e51

Browse files
committed
lint: cargo fmt & clippy
1 parent 29c8afb commit 5772e51

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

src/command/bootstrap.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use anyhow::Context;
2-
use std::path::PathBuf;
3-
use tokio::task::JoinSet;
42
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
53
use std::io::IsTerminal;
4+
use std::path::{Path, PathBuf};
5+
use tokio::task::JoinSet;
66

77
use crate::files::archive_filepath_from_opts;
88

@@ -159,7 +159,8 @@ impl Bootstrap {
159159

160160
if download_node_archives {
161161
tracing::info!("downloading node archives for chain {}", chain_id);
162-
Bootstrap::download_node_archives_static(&chain_id, &home, force).await
162+
Bootstrap::download_node_archives_static(&chain_id, &home, force)
163+
.await
163164
.context("failed to download node archives")?;
164165
}
165166

@@ -169,7 +170,7 @@ impl Bootstrap {
169170
/// Download all NodeArchives for a given chain in parallel with progress bars.
170171
pub async fn download_node_archives_static(
171172
chain_id: &str,
172-
home: &PathBuf,
173+
home: &Path,
173174
force: bool,
174175
) -> anyhow::Result<()> {
175176
let node_archive_series = crate::history::NodeArchiveSeries::from_chain_id(chain_id)
@@ -199,7 +200,7 @@ impl Bootstrap {
199200
let mut join_set = JoinSet::new();
200201

201202
for (index, archive) in archives.into_iter().enumerate() {
202-
let home_dir = home.clone();
203+
let home_dir = home.to_path_buf();
203204
let chain_id_clone = chain_id.to_string();
204205
let multi_progress_clone = multi_progress.clone();
205206

@@ -242,11 +243,7 @@ impl Bootstrap {
242243
for error in &errors {
243244
tracing::error!(" {}", error);
244245
}
245-
anyhow::bail!(
246-
"{} of {} downloads failed",
247-
errors.len(),
248-
num_archives
249-
);
246+
anyhow::bail!("{} of {} downloads failed", errors.len(), num_archives);
250247
}
251248

252249
tracing::info!(
@@ -260,7 +257,7 @@ impl Bootstrap {
260257

261258
async fn download_single_node_archive(
262259
archive: crate::history::NodeArchive,
263-
home: &PathBuf,
260+
home: &Path,
264261
chain_id: &str,
265262
force: bool,
266263
_index: usize,
@@ -330,18 +327,19 @@ impl Bootstrap {
330327
let existing_hash = Self::get_sha256sum(dest_file)?;
331328
if existing_hash == checksum_sha256 {
332329
if let Some(pb) = progress_bar {
333-
pb.set_message(format!("{}: Already exists with correct checksum", basename));
330+
pb.set_message(format!(
331+
"{}: Already exists with correct checksum",
332+
basename
333+
));
334334
}
335335
return Ok(());
336-
} else {
337-
if let Some(pb) = progress_bar {
338-
pb.set_message(format!("{}: Re-downloading (checksum mismatch)", basename));
339-
}
336+
} else if let Some(pb) = progress_bar {
337+
pb.set_message(format!("{}: Re-downloading (checksum mismatch)", basename));
340338
}
341339
}
342340

343341
let client = Client::new();
344-
342+
345343
let total_size = match client.head(download_url.clone()).send().await {
346344
Ok(response) => response
347345
.headers()
@@ -366,13 +364,13 @@ impl Bootstrap {
366364
}
367365

368366
let response = client.get(download_url.clone()).send().await?;
369-
367+
370368
if !response.status().is_success() {
371369
anyhow::bail!("Failed to download: HTTP {}", response.status());
372370
}
373371

374-
let mut file = std::fs::File::create(dest_file)
375-
.context("failed to create destination file")?;
372+
let mut file =
373+
std::fs::File::create(dest_file).context("failed to create destination file")?;
376374

377375
let mut stream = response.bytes_stream();
378376
let mut downloaded = 0u64;

src/command/check.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl Check {
7373

7474
Err(_) => {
7575
println!("❌ found gaps of missing blocks");
76-
failed_checks = failed_checks + 1;
76+
failed_checks += 1;
7777
}
7878
}
7979

@@ -89,7 +89,7 @@ impl Check {
8989
"❌ genesis records are missing; expected {}",
9090
expected_num_geneses
9191
);
92-
failed_checks = failed_checks + 1;
92+
failed_checks += 1;
9393
}
9494
}
9595
if failed_checks == 0 {

src/history/reindexer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use flate2::read::GzDecoder;
2-
use std::path::PathBuf;
2+
use std::path::{Path, PathBuf};
33
use url::Url;
44

55
use std::fs::File;
@@ -76,7 +76,7 @@ impl ReindexerArchive {
7676
}
7777

7878
/// Fetch the archive from the `download_url` and save it locally.
79-
pub async fn download(&self, dest_file: &PathBuf) -> anyhow::Result<()> {
79+
pub async fn download(&self, dest_file: &Path) -> anyhow::Result<()> {
8080
crate::history::download(&self.download_url, dest_file, &self.checksum_sha256).await?;
8181
Ok(())
8282
}

0 commit comments

Comments
 (0)