Skip to content

Commit

Permalink
Fix BP prune timer and don't panic on persistence notification failure
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull authored and luckysori committed Jul 17, 2023
1 parent ab73cce commit 40bd0c4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lightning-background-processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ macro_rules! define_run_body {
// falling back to our usual hourly prunes. This avoids short-lived clients never
// pruning their network graph. We run once 60 seconds after startup before
// continuing our normal cadence.
if $timer_elapsed(&mut last_prune_call, if have_pruned { NETWORK_PRUNE_TIMER } else { FIRST_NETWORK_PRUNE_TIMER }) {
let prune_timer = if have_pruned { NETWORK_PRUNE_TIMER } else { FIRST_NETWORK_PRUNE_TIMER };
if $timer_elapsed(&mut last_prune_call, prune_timer) {
// The network graph must not be pruned while rapid sync completion is pending
if let Some(network_graph) = $gossip_sync.prunable_network_graph() {
#[cfg(feature = "std")] {
Expand All @@ -352,6 +353,8 @@ macro_rules! define_run_body {
last_prune_call = $get_timer(NETWORK_PRUNE_TIMER);
have_pruned = true;
}
let prune_timer = if have_pruned { NETWORK_PRUNE_TIMER } else { FIRST_NETWORK_PRUNE_TIMER };
last_prune_call = $get_timer(prune_timer);
}

if $timer_elapsed(&mut last_scorer_persist_call, SCORER_PERSIST_TIMER) {
Expand Down Expand Up @@ -788,7 +791,10 @@ mod tests {

if key == "network_graph" {
if let Some(sender) = &self.graph_persistence_notifier {
sender.send(()).unwrap();
match sender.send(()) {
Ok(()) => {},
Err(std::sync::mpsc::SendError(())) => println!("Persister failed to notify as receiver went away."),
}
};

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

0 comments on commit 40bd0c4

Please sign in to comment.