Skip to content

Commit

Permalink
chore: reduce dag recrawl interval
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuef committed Jun 4, 2024
1 parent 88f89fd commit 6935e93
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions sn_auditor/src/dag_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub const SPEND_DAG_SVG_FILENAME: &str = "spend_dag.svg";
/// Store a locally copy to restore on restart
pub const BETA_PARTICIPANTS_FILENAME: &str = "beta_participants.txt";

const REATTEMPT_INTERVAL: Duration = Duration::from_secs(3600);
const DAG_RECRAWL_INTERVAL: Duration = Duration::from_secs(60);
const SPENDS_PROCESSING_BUFFER_SIZE: usize = 4096;

/// Abstraction for the Spend DAG database
Expand Down Expand Up @@ -223,8 +223,8 @@ impl SpendDagDb {
let addrs_to_get = utxos_to_fetch.keys().cloned().collect::<BTreeSet<_>>();

if addrs_to_get.is_empty() {
debug!("Sleeping for {REATTEMPT_INTERVAL:?} until next re-attempt...");
tokio::time::sleep(REATTEMPT_INTERVAL).await;
debug!("Sleeping for {DAG_RECRAWL_INTERVAL:?} until next re-attempt...");
tokio::time::sleep(DAG_RECRAWL_INTERVAL).await;
continue;
}

Expand All @@ -241,7 +241,7 @@ impl SpendDagDb {
utxo_addresses.extend(
new_utxos
.into_iter()
.map(|a| (a, Instant::now() + REATTEMPT_INTERVAL)),
.map(|a| (a, Instant::now() + DAG_RECRAWL_INTERVAL)),
);

// write updates to local DAG and save to disk
Expand Down
6 changes: 3 additions & 3 deletions sn_auditor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::path::PathBuf;
use tiny_http::{Response, Server};

/// Backup the beta rewards in a timestamped json file
const BETA_REWARDS_BACKOUP_INTERVAL_SECS: u64 = 20 * 60;
const BETA_REWARDS_BACKUP_INTERVAL_SECS: u64 = 20 * 60;

#[derive(Parser)]
#[command(author, version, about, long_about = None)]
Expand Down Expand Up @@ -163,10 +163,10 @@ fn initialize_background_rewards_backup(dag: SpendDagDb) {
tokio::spawn(async move {
loop {
trace!(
"Sleeping for {BETA_REWARDS_BACKOUP_INTERVAL_SECS} seconds before next backup..."
"Sleeping for {BETA_REWARDS_BACKUP_INTERVAL_SECS} seconds before next backup..."
);
tokio::time::sleep(tokio::time::Duration::from_secs(
BETA_REWARDS_BACKOUP_INTERVAL_SECS,
BETA_REWARDS_BACKUP_INTERVAL_SECS,
))
.await;
println!("Backing up beta rewards...");
Expand Down
5 changes: 4 additions & 1 deletion sn_node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,10 @@ impl Node {
PERIODIC_REPLICATION_INTERVAL_MAX_S / 2..PERIODIC_REPLICATION_INTERVAL_MAX_S,
);
let balance_forward_time = Duration::from_secs(balance_forward_interval);
debug!("BalanceForward interval set to {balance_forward_time:?}");
debug!(
"BalanceForward interval set to {balance_forward_time:?} to: {:?}",
PAYMENT_FORWARD_PK.to_hex(),
);

let mut balance_forward_interval = tokio::time::interval(balance_forward_time);
let _ = balance_forward_interval.tick().await; // first tick completes immediately
Expand Down

0 comments on commit 6935e93

Please sign in to comment.