@@ -288,37 +288,32 @@ impl BackgroundProcessor {
288
288
// pruning their network graph. We run once 60 seconds after startup before
289
289
// continuing our normal cadence.
290
290
if last_prune_call. elapsed ( ) . as_secs ( ) > if have_pruned { NETWORK_PRUNE_TIMER } else { FIRST_NETWORK_PRUNE_TIMER } {
291
-
292
291
// The network graph must not be pruned while rapid sync completion is pending
293
292
log_trace ! ( logger, "Assessing prunability of network graph" ) ;
294
- let should_prune = match rapid_gossip_sync. as_ref ( ) {
295
- Some ( rapid_sync) => rapid_sync. is_initial_sync_complete ( ) ,
296
- None => true
293
+ let graph_to_prune = match rapid_gossip_sync. as_ref ( ) {
294
+ Some ( rapid_sync) => {
295
+ if rapid_sync. is_initial_sync_complete ( ) {
296
+ Some ( rapid_sync. network_graph ( ) )
297
+ } else {
298
+ None
299
+ }
300
+ } ,
301
+ None => net_graph_msg_handler. as_ref ( ) . map_or ( None , |handler| Some ( handler. network_graph ( ) ) )
297
302
} ;
298
303
299
- if should_prune {
300
- log_trace ! ( logger, "Pruning network graph of stale entries" ) ;
301
- let network_graph_optional = if let Some ( ref handler) = net_graph_msg_handler {
302
- Some ( handler. network_graph ( ) )
303
- } else if let Some ( ref rapid_sync) = rapid_gossip_sync {
304
- Some ( rapid_sync. network_graph ( ) )
305
- } else {
306
- None
307
- } ;
308
-
309
- if let Some ( network_graph_reference) = network_graph_optional {
310
- network_graph_reference. remove_stale_channels ( ) ;
311
-
312
- if let Err ( e) = persister. persist_graph ( network_graph_reference) {
313
- log_error ! ( logger, "Error: Failed to persist network graph, check your disk and permissions {}" , e)
314
- }
304
+ if let Some ( network_graph_reference) = graph_to_prune {
305
+ network_graph_reference. remove_stale_channels ( ) ;
315
306
316
- last_prune_call = Instant :: now ( ) ;
317
- have_pruned = true ;
307
+ if let Err ( e ) = persister . persist_graph ( network_graph_reference ) {
308
+ log_error ! ( logger , "Error: Failed to persist network graph, check your disk and permissions {}" , e )
318
309
}
310
+
311
+ last_prune_call = Instant :: now ( ) ;
312
+ have_pruned = true ;
319
313
} else {
320
314
log_trace ! ( logger, "Not pruning network graph due to pending gossip sync" ) ;
321
315
}
316
+
322
317
}
323
318
324
319
if last_scorer_persist_call. elapsed ( ) . as_secs ( ) > SCORER_PERSIST_TIMER {
0 commit comments