Skip to content

Commit

Permalink
previous instead of last
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex6323 committed Apr 29, 2022
1 parent 49e3c29 commit fb98cbd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bee-ledger/src/workers/pruning/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{types::LedgerIndex, workers::pruning::config::PruningConfig};

const PRUNING_BATCH_SIZE_MAX: u32 = 200;

static LAST_PRUNING_BY_SIZE: AtomicU64 = AtomicU64::new(0);
static PREVIOUS_PRUNING_BY_SIZE: AtomicU64 = AtomicU64::new(0);

/// Reasons for skipping pruning.
#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -56,11 +56,11 @@ pub(crate) fn should_prune<S: StorageBackend>(
}

let pruning_by_size = if pruning_config.db_size().enabled() {
let last = Duration::from_secs(LAST_PRUNING_BY_SIZE.load(Ordering::Relaxed));
let prev = Duration::from_secs(PREVIOUS_PRUNING_BY_SIZE.load(Ordering::Relaxed));
// Panic: should not cause problems on properly set up hosts.
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();

if now < last + pruning_config.db_size().cooldown_time() {
if now < prev + pruning_config.db_size().cooldown_time() {
Err(PruningSkipReason::Cooldown)
} else {
let actual_size = {
Expand Down Expand Up @@ -93,7 +93,7 @@ pub(crate) fn should_prune<S: StorageBackend>(
log::debug!("Num bytes to prune: {num_bytes_to_prune}");

// Store the time we issued a pruning-by-size.
LAST_PRUNING_BY_SIZE.store(now.as_secs(), Ordering::Relaxed);
PREVIOUS_PRUNING_BY_SIZE.store(now.as_secs(), Ordering::Relaxed);

Ok(PruningTask::ByDbSize { num_bytes_to_prune })
}
Expand Down

0 comments on commit fb98cbd

Please sign in to comment.