@@ -79,6 +79,11 @@ const PING_TIMER: u64 = 1;
7979/// Prune the network graph of stale entries hourly.
8080const 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) ) ]
8388const 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 {
@@ -307,12 +313,16 @@ impl BackgroundProcessor {
307313 } else {
308314 log_trace ! ( logger, "Not pruning network graph, either due to pending rapid gossip sync or absence of a prunable graph." ) ;
309315 }
316+ }
317+
318+ if last_scorer_persist_call. elapsed ( ) . as_secs ( ) > SCORER_PERSIST_TIMER {
310319 if let Some ( ref scorer) = scorer {
311320 log_trace ! ( logger, "Persisting scorer" ) ;
312321 if let Err ( e) = persister. persist_scorer ( & scorer) {
313322 log_error ! ( logger, "Error: Failed to persist scorer, check your disk and permissions {}" , e)
314323 }
315324 }
325+ last_scorer_persist_call = Instant :: now ( ) ;
316326 }
317327 }
318328
0 commit comments