mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
fix(pruner): percentage progress (#4197)
This commit is contained in:
@ -240,16 +240,14 @@ impl<DB: Database> Pruner<DB> {
|
||||
};
|
||||
let total = range.clone().count();
|
||||
|
||||
let mut processed = 0;
|
||||
provider.prune_table_with_iterator_in_batches::<tables::Receipts>(
|
||||
range,
|
||||
self.batch_sizes.receipts,
|
||||
|rows| {
|
||||
processed += rows;
|
||||
trace!(
|
||||
target: "pruner",
|
||||
%rows,
|
||||
progress = format!("{:.1}%", 100.0 * processed as f64 / total as f64),
|
||||
progress = format!("{:.1}%", 100.0 * rows as f64 / total as f64),
|
||||
"Pruned receipts"
|
||||
);
|
||||
},
|
||||
@ -348,16 +346,14 @@ impl<DB: Database> Pruner<DB> {
|
||||
};
|
||||
let total = range.clone().count();
|
||||
|
||||
let mut processed = 0;
|
||||
provider.prune_table_with_range_in_batches::<tables::TxSenders>(
|
||||
range,
|
||||
self.batch_sizes.transaction_senders,
|
||||
|rows, _| {
|
||||
processed += rows;
|
||||
trace!(
|
||||
target: "pruner",
|
||||
%rows,
|
||||
progress = format!("{:.1}%", 100.0 * processed as f64 / total as f64),
|
||||
progress = format!("{:.1}%", 100.0 * rows as f64 / total as f64),
|
||||
"Pruned transaction senders"
|
||||
);
|
||||
},
|
||||
|
||||
@ -630,7 +630,7 @@ impl<'this, TX: DbTxMut<'this> + DbTx<'this>> DatabaseProvider<'this, TX> {
|
||||
}
|
||||
|
||||
/// Prune the table for the specified pre-sorted key iterator, calling `chunk_callback` after
|
||||
/// every `batch_size` pruned rows.
|
||||
/// every `batch_size` pruned rows with number of total rows pruned.
|
||||
///
|
||||
/// Returns number of rows pruned.
|
||||
pub fn prune_table_with_iterator_in_batches<T: Table>(
|
||||
@ -649,12 +649,12 @@ impl<'this, TX: DbTxMut<'this> + DbTx<'this>> DatabaseProvider<'this, TX> {
|
||||
deleted += 1;
|
||||
|
||||
if deleted % batch_size == 0 {
|
||||
batch_callback(batch_size);
|
||||
batch_callback(deleted);
|
||||
}
|
||||
}
|
||||
|
||||
if deleted % batch_size != 0 {
|
||||
batch_callback(deleted % batch_size);
|
||||
batch_callback(deleted);
|
||||
}
|
||||
|
||||
Ok(deleted)
|
||||
|
||||
Reference in New Issue
Block a user