Skip to content

Commit 2ff1bba

Browse files
committed
Respond to comments
1 parent 1b2f65d commit 2ff1bba

File tree

1 file changed

+17
-22
lines changed
  • lightning-background-processor/src

1 file changed

+17
-22
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -288,37 +288,32 @@ impl BackgroundProcessor {
288288
// pruning their network graph. We run once 60 seconds after startup before
289289
// continuing our normal cadence.
290290
if last_prune_call.elapsed().as_secs() > if have_pruned { NETWORK_PRUNE_TIMER } else { FIRST_NETWORK_PRUNE_TIMER } {
291-
292291
// The network graph must not be pruned while rapid sync completion is pending
293292
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()))
297302
};
298303

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();
315306

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)
318309
}
310+
311+
last_prune_call = Instant::now();
312+
have_pruned = true;
319313
} else {
320314
log_trace!(logger, "Not pruning network graph due to pending gossip sync");
321315
}
316+
322317
}
323318

324319
if last_scorer_persist_call.elapsed().as_secs() > SCORER_PERSIST_TIMER {

0 commit comments

Comments
 (0)