Skip to content

Commit 8cdac12

Browse files
committed
Create separate timer for scorer persistence in background processor
1 parent d509e52 commit 8cdac12

File tree

1 file changed

+10
-0
lines changed
  • lightning-background-processor/src

1 file changed

+10
-0
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ const PING_TIMER: u64 = 1;
7979
/// Prune the network graph of stale entries hourly.
8080
const NETWORK_PRUNE_TIMER: u64 = 60 * 60;
8181

82+
#[cfg(all(not(test), debug_assertions))]
83+
const SCORER_PERSIST_TIMER: u64 = 30;
84+
#[cfg(test)]
85+
const SCORER_PERSIST_TIMER: u64 = 1;
86+
8287
#[cfg(not(test))]
8388
const FIRST_NETWORK_PRUNE_TIMER: u64 = 60;
8489
#[cfg(test)]
@@ -214,6 +219,7 @@ impl BackgroundProcessor {
214219
let mut last_freshness_call = Instant::now();
215220
let mut last_ping_call = Instant::now();
216221
let mut last_prune_call = Instant::now();
222+
let mut last_scorer_persist_call = Instant::now();
217223
let mut have_pruned = false;
218224

219225
loop {
@@ -305,12 +311,16 @@ impl BackgroundProcessor {
305311
log_trace!(logger, "Not pruning network graph due to pending gossip sync");
306312
}
307313
}
314+
}
315+
316+
if last_scorer_persist_call.elapsed().as_secs() > SCORER_PERSIST_TIMER {
308317
if let Some(ref scorer) = scorer {
309318
log_trace!(logger, "Persisting scorer");
310319
if let Err(e) = persister.persist_scorer(&scorer) {
311320
log_error!(logger, "Error: Failed to persist scorer, check your disk and permissions {}", e)
312321
}
313322
}
323+
last_scorer_persist_call = Instant::now();
314324
}
315325
}
316326

0 commit comments

Comments
 (0)