Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 932a760

Browse files
committed
Log actual and target storage size in 'should_prune'
1 parent 226fdc2 commit 932a760

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

bee-ledger/src/workers/consensus/worker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ where
356356
}
357357
}
358358

359-
match should_prune(&tangle, ledger_index, pruning_delay, &pruning_config) {
359+
match should_prune(&tangle, &storage, ledger_index, pruning_delay, &pruning_config) {
360360
Ok((start_index, target_index)) => {
361361
if let Err(e) =
362362
prune::prune(&tangle, &storage, &bus, start_index, target_index, &pruning_config)

bee-ledger/src/workers/pruning/condition.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,33 @@ pub enum PruningSkipReason {
1717
BelowThreshold { reached_in: u32 },
1818
}
1919

20-
pub(crate) fn should_prune<B: StorageBackend>(
21-
tangle: &Tangle<B>,
20+
pub(crate) fn should_prune<S: StorageBackend>(
21+
tangle: &Tangle<S>,
22+
storage: &S,
2223
ledger_index: LedgerIndex,
23-
pruning_delay: u32,
24+
max_milestones_to_keep: u32,
2425
config: &PruningConfig,
25-
) -> Result<(MilestoneIndex, MilestoneIndex), PruningSkipReason> {
26-
if !config.pruning_milestones().enabled() {
26+
) -> Result<(MilestoneIndex, MilestoneIndex), PruningSkipReason>
27+
{
28+
log::debug!(
29+
"Storage size: actual {} limit {}",
30+
storage.size().expect("ok storage size").expect("some storage size"),
31+
config.pruning_by_size().target_size()
32+
);
33+
34+
if !config.pruning_milestones().enabled() && !config.pruning_by_size().enabled() {
2735
return Err(PruningSkipReason::Disabled);
2836
}
2937

3038
let pruning_index = *tangle.get_pruning_index() + 1;
31-
let pruning_threshold = pruning_index + pruning_delay;
39+
let pruning_threshold = pruning_index + max_milestones_to_keep;
3240

3341
if *ledger_index < pruning_threshold {
3442
Err(PruningSkipReason::BelowThreshold {
3543
reached_in: pruning_threshold - *ledger_index,
3644
})
3745
} else {
38-
let target_pruning_index = *ledger_index - pruning_delay;
46+
let target_pruning_index = *ledger_index - max_milestones_to_keep;
3947

4048
Ok((
4149
pruning_index.into(),

bee-ledger/src/workers/pruning/prune.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ pub async fn prune<S: StorageBackend>(
5959
let index = MilestoneIndex(index);
6060

6161
debug!("Pruning milestone {}...", index);
62-
debug!("Storage size: actual {} limit {}", storage.size().expect("ok storage size").expect("some storage size"), config.pruning_by_size().target_size());
6362

6463
// Measurement of the full pruning step.
6564
let full_prune = Instant::now();

0 commit comments

Comments
 (0)