From: Matt Corallo Date: Tue, 20 Aug 2024 14:32:44 +0000 (+0000) Subject: Require an OM in BP as this should generally be true and its easier to map X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=28aca7d1b285a801d23d5a96ed9241bf0006fd19;p=rust-lightning Require an OM in BP as this should generally be true and its easier to map --- diff --git a/lightning-background-processor/src/lib.rs b/lightning-background-processor/src/lib.rs index 410f28a2e..9fa8437b7 100644 --- a/lightning-background-processor/src/lib.rs +++ b/lightning-background-processor/src/lib.rs @@ -925,7 +925,7 @@ impl BackgroundProcessor { SC: for<'b> WriteableScore<'b>, >( persister: PS, event_handler: EH, chain_monitor: M, channel_manager: CM, - onion_messenger: Option, gossip_sync: GossipSync, peer_manager: PM, + onion_messenger: OM, gossip_sync: GossipSync, peer_manager: PM, logger: L, scorer: Option, ) -> Self where @@ -962,34 +962,27 @@ impl BackgroundProcessor { } event_handler.handle_event(event) }; + let om_opt = Some(&*onion_messenger); define_run_body!( persister, chain_monitor, chain_monitor.process_pending_events(&event_handler), channel_manager, channel_manager.get_cm().process_pending_events(&event_handler), - onion_messenger, - if let Some(om) = &onion_messenger { - om.get_om().process_pending_events(&event_handler) - }, + om_opt, + onion_messenger.get_om().process_pending_events(&event_handler), peer_manager, gossip_sync, logger, scorer, stop_thread.load(Ordering::Acquire), { - let sleeper = if let Some(om) = onion_messenger.as_ref() { + let sleeper = Sleeper::from_three_futures( &channel_manager.get_cm().get_event_or_persistence_needed_future(), &chain_monitor.get_update_future(), - &om.get_om().get_update_future(), - ) - } else { - Sleeper::from_two_futures( - &channel_manager.get_cm().get_event_or_persistence_needed_future(), - &chain_monitor.get_update_future(), - ) - }; + &onion_messenger.get_om().get_update_future(), + ); sleeper.wait_timeout(Duration::from_millis(100)); }, |_| Instant::now(),