@@ -288,28 +288,36 @@ 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
- if let Some ( ref handler) = net_graph_msg_handler {
292
- log_trace ! ( logger, "Assessing prunability of network graph" ) ;
293
291
294
- // The network graph must not be pruned while rapid sync completion is pending
295
- let should_prune = match rapid_gossip_sync. as_ref ( ) {
296
- Some ( rapid_sync) => rapid_sync. is_initial_sync_complete ( ) ,
297
- None => true
292
+ // The network graph must not be pruned while rapid sync completion is pending
293
+ 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
297
+ } ;
298
+
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
298
307
} ;
299
308
300
- if should_prune {
301
- log_trace ! ( logger, "Pruning network graph of stale entries" ) ;
302
- handler. network_graph ( ) . remove_stale_channels ( ) ;
309
+ if let Some ( network_graph_reference) = network_graph_optional {
310
+ network_graph_reference. remove_stale_channels ( ) ;
303
311
304
- if let Err ( e) = persister. persist_graph ( handler . network_graph ( ) ) {
312
+ if let Err ( e) = persister. persist_graph ( network_graph_reference ) {
305
313
log_error ! ( logger, "Error: Failed to persist network graph, check your disk and permissions {}" , e)
306
314
}
307
315
308
316
last_prune_call = Instant :: now ( ) ;
309
317
have_pruned = true ;
310
- } else {
311
- log_trace ! ( logger, "Not pruning network graph due to pending gossip sync" ) ;
312
318
}
319
+ } else {
320
+ log_trace ! ( logger, "Not pruning network graph due to pending gossip sync" ) ;
313
321
}
314
322
}
315
323
0 commit comments