Skip to content

Commit

Permalink
fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
wanyvic committed Mar 5, 2024
1 parent 1fa539d commit 5263bee
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,26 +270,28 @@ impl Index {
let once = Once::new();
let progress_bar = Mutex::new(None);

let database = match Database::builder()
.set_cache_size(db_cache_size)
.set_repair_callback(move |progress: &mut RepairSession| {
once.call_once(|| println!("Index file `{}` needs recovery. This can take a long time, especially for the --index-sats index.", index_path.display()));

if !(cfg!(test) || log_enabled!(log::Level::Info) || integration_test()) {
let mut guard = progress_bar.lock().unwrap();
let repair_callback = move |progress: &mut RepairSession| {
once.call_once(|| println!("Index file `{}` needs recovery. This can take a long time, especially for the --index-sats index.", index_path.display()));

if !(cfg!(test) || log_enabled!(log::Level::Info) || integration_test()) {
let mut guard = progress_bar.lock().unwrap();

let progress_bar = guard.get_or_insert_with(|| {
let progress_bar = ProgressBar::new(100);
progress_bar.set_style(
ProgressStyle::with_template("[repairing database] {wide_bar} {pos}/{len}").unwrap(),
);
progress_bar
});

let progress_bar = guard.get_or_insert_with(|| {
let progress_bar = ProgressBar::new(100);
progress_bar.set_style(
ProgressStyle::with_template("[repairing database] {wide_bar} {pos}/{len}").unwrap(),
);
progress_bar
});
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
progress_bar.set_position((progress.progress() * 100.0) as u64);
}
};

#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
progress_bar.set_position((progress.progress() * 100.0) as u64);
}
})
let database = match Database::builder()
.set_cache_size(db_cache_size)
.set_repair_callback(repair_callback)
.open(&path)
{
Ok(database) => {
Expand Down Expand Up @@ -317,7 +319,6 @@ impl Index {
}
}


index_runes = Self::is_statistic_set(&statistics, Statistic::IndexRunes)?;
index_sats = Self::is_statistic_set(&statistics, Statistic::IndexSats)?;
index_transactions = Self::is_statistic_set(&statistics, Statistic::IndexTransactions)?;
Expand Down Expand Up @@ -379,9 +380,17 @@ impl Index {
index_sats = options.index_sats;
index_transactions = options.index_transactions;

Self::set_statistic(&mut statistics, Statistic::IndexRunes, u64::from(index_runes))?;
Self::set_statistic(
&mut statistics,
Statistic::IndexRunes,
u64::from(index_runes),
)?;
Self::set_statistic(&mut statistics, Statistic::IndexSats, u64::from(index_sats))?;
Self::set_statistic(&mut statistics, Statistic::IndexTransactions, u64::from(index_transactions))?;
Self::set_statistic(
&mut statistics,
Statistic::IndexTransactions,
u64::from(index_transactions),
)?;
Self::set_statistic(&mut statistics, Statistic::Schema, SCHEMA_VERSION)?;
}

Expand Down

0 comments on commit 5263bee

Please sign in to comment.