Skip to content

Commit ad8ab4d

Browse files
committed
Prune and persist RGS network graph after initial sync
Previously we would wait 60 seconds after startup, however for RGS we prune/persist after its initial sync since 60 seconds is likely too long.
1 parent ec3aa49 commit ad8ab4d

File tree

1 file changed

+8
-2
lines changed
  • lightning-background-processor/src

1 file changed

+8
-2
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,15 @@ macro_rules! define_run_body {
351351
// Note that we want to run a graph prune once not long after startup before
352352
// falling back to our usual hourly prunes. This avoids short-lived clients never
353353
// pruning their network graph. We run once 60 seconds after startup before
354-
// continuing our normal cadence.
354+
// continuing our normal cadence. For RGS, since 60 seconds is likely too long,
355+
// we prune after an initial sync completes.
355356
let prune_timer = if have_pruned { NETWORK_PRUNE_TIMER } else { FIRST_NETWORK_PRUNE_TIMER };
356-
if $timer_elapsed(&mut last_prune_call, prune_timer) {
357+
let prune_timer_elapsed = $timer_elapsed(&mut last_prune_call, prune_timer);
358+
let should_prune = match $gossip_sync {
359+
GossipSync::Rapid(_) => !have_pruned || prune_timer_elapsed,
360+
_ => prune_timer_elapsed,
361+
};
362+
if should_prune {
357363
// The network graph must not be pruned while rapid sync completion is pending
358364
if let Some(network_graph) = $gossip_sync.prunable_network_graph() {
359365
#[cfg(feature = "std")] {

0 commit comments

Comments
 (0)