Skip to content

Commit 9787b28

Browse files
committed
Drop DecoratingEventHandler in favor of inline closure
1 parent 8d20ebc commit 9787b28

File tree

1 file changed

+6
-36
lines changed
  • lightning-background-processor/src

1 file changed

+6
-36
lines changed

lightning-background-processor/src/lib.rs

+6-36
Original file line numberDiff line numberDiff line change
@@ -202,39 +202,6 @@ fn handle_network_graph_update<L: Deref>(
202202
}
203203
}
204204

205-
/// Decorates an [`EventHandler`] with common functionality provided by standard [`EventHandler`]s.
206-
struct DecoratingEventHandler<
207-
'a,
208-
E: EventHandler,
209-
PGS: Deref<Target = P2PGossipSync<G, A, L>>,
210-
RGS: Deref<Target = RapidGossipSync<G, L>>,
211-
G: Deref<Target = NetworkGraph<L>>,
212-
A: Deref,
213-
L: Deref,
214-
>
215-
where A::Target: chain::Access, L::Target: Logger {
216-
event_handler: E,
217-
gossip_sync: &'a GossipSync<PGS, RGS, G, A, L>,
218-
}
219-
220-
impl<
221-
'a,
222-
E: EventHandler,
223-
PGS: Deref<Target = P2PGossipSync<G, A, L>>,
224-
RGS: Deref<Target = RapidGossipSync<G, L>>,
225-
G: Deref<Target = NetworkGraph<L>>,
226-
A: Deref,
227-
L: Deref,
228-
> EventHandler for DecoratingEventHandler<'a, E, PGS, RGS, G, A, L>
229-
where A::Target: chain::Access, L::Target: Logger {
230-
fn handle_event(&self, event: Event) {
231-
if let Some(network_graph) = self.gossip_sync.network_graph() {
232-
handle_network_graph_update(network_graph, &event)
233-
}
234-
self.event_handler.handle_event(event);
235-
}
236-
}
237-
238205
macro_rules! define_run_body {
239206
($persister: ident, $chain_monitor: ident, $process_chain_monitor_events: expr,
240207
$channel_manager: ident, $process_channel_manager_events: expr,
@@ -536,9 +503,12 @@ impl BackgroundProcessor {
536503
let stop_thread = Arc::new(AtomicBool::new(false));
537504
let stop_thread_clone = stop_thread.clone();
538505
let handle = thread::spawn(move || -> Result<(), std::io::Error> {
539-
let event_handler = DecoratingEventHandler {
540-
event_handler,
541-
gossip_sync: &gossip_sync,
506+
let event_handler = |event| {
507+
let network_graph = gossip_sync.network_graph();
508+
if let Some(network_graph) = network_graph {
509+
handle_network_graph_update(network_graph, &event)
510+
}
511+
event_handler.handle_event(event);
542512
};
543513
define_run_body!(persister, chain_monitor, chain_monitor.process_pending_events(&event_handler),
544514
channel_manager, channel_manager.process_pending_events(&event_handler),

0 commit comments

Comments
 (0)