Skip to content

Commit d9c14d4

Browse files
committed
Fix BP prune timer and don't panic on persistence notification failure
1 parent d7de357 commit d9c14d4

File tree

1 file changed

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

1 file changed

+8
-3
lines changed

lightning-background-processor/src/lib.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ macro_rules! define_run_body {
342342
// falling back to our usual hourly prunes. This avoids short-lived clients never
343343
// pruning their network graph. We run once 60 seconds after startup before
344344
// continuing our normal cadence.
345-
if $timer_elapsed(&mut last_prune_call, if have_pruned { NETWORK_PRUNE_TIMER } else { FIRST_NETWORK_PRUNE_TIMER }) {
345+
let prune_timer = if have_pruned { NETWORK_PRUNE_TIMER } else { FIRST_NETWORK_PRUNE_TIMER };
346+
if $timer_elapsed(&mut last_prune_call, prune_timer) {
346347
// The network graph must not be pruned while rapid sync completion is pending
347348
if let Some(network_graph) = $gossip_sync.prunable_network_graph() {
348349
#[cfg(feature = "std")] {
@@ -360,7 +361,8 @@ macro_rules! define_run_body {
360361

361362
have_pruned = true;
362363
}
363-
last_prune_call = $get_timer(NETWORK_PRUNE_TIMER);
364+
let prune_timer = if have_pruned { NETWORK_PRUNE_TIMER } else { FIRST_NETWORK_PRUNE_TIMER };
365+
last_prune_call = $get_timer(prune_timer);
364366
}
365367

366368
if $timer_elapsed(&mut last_scorer_persist_call, SCORER_PERSIST_TIMER) {
@@ -867,7 +869,10 @@ mod tests {
867869

868870
if key == "network_graph" {
869871
if let Some(sender) = &self.graph_persistence_notifier {
870-
sender.send(()).unwrap();
872+
match sender.send(()) {
873+
Ok(()) => {},
874+
Err(std::sync::mpsc::SendError(())) => println!("Persister failed to notify as receiver went away."),
875+
}
871876
};
872877

873878
if let Some((error, message)) = self.graph_error {

0 commit comments

Comments
 (0)