Skip to content

Commit

Permalink
fix: backup engine check (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
renancloudwalk authored Apr 25, 2024
1 parent 0edee36 commit 9e28b7d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/eth/storage/rocks/rocks_permanent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::eth::storage::PermanentStorage;
use crate::eth::storage::StorageError;

/// used for multiple purposes, such as TPS counting and backup management
const TRANSACTION_LOOP_THRESHOLD: usize = 420_000;
const TRANSACTION_LOOP_THRESHOLD: usize = 120_000;

static TRANSACTIONS_COUNT: AtomicUsize = AtomicUsize::new(0);

Expand Down Expand Up @@ -220,12 +220,13 @@ impl PermanentStorage for RocksPermanentStorage {
);

let previous_count = TRANSACTIONS_COUNT.load(Ordering::Relaxed);
let current_count = TRANSACTIONS_COUNT.fetch_add(block.transactions.len(), Ordering::Relaxed);
let _ = TRANSACTIONS_COUNT.fetch_add(block.transactions.len(), Ordering::Relaxed);
let current_count = TRANSACTIONS_COUNT.load(Ordering::Relaxed);

// for every multiple of TRANSACTION_LOOP_THRESHOLD transactions, send a Backup signal
if previous_count % TRANSACTION_LOOP_THRESHOLD > current_count % TRANSACTION_LOOP_THRESHOLD {
let x = Arc::clone(&self.state.backup_trigger);
x.send(()).await.unwrap();
let backup_channel = Arc::clone(&self.state.backup_trigger);
backup_channel.send(()).await.unwrap();
TRANSACTIONS_COUNT.store(0, Ordering::Relaxed);
}

Expand Down

0 comments on commit 9e28b7d

Please sign in to comment.