@@ -192,43 +192,6 @@ where
192192 }
193193}
194194
195- /// Decorates an [`EventHandler`] with common functionality provided by standard [`EventHandler`]s.
196- struct DecoratingEventHandler <
197- ' a ,
198- E : EventHandler ,
199- PGS : Deref < Target = P2PGossipSync < G , A , L > > ,
200- RGS : Deref < Target = RapidGossipSync < G , L > > ,
201- G : Deref < Target = NetworkGraph < L > > ,
202- A : Deref ,
203- L : Deref ,
204- >
205- where A :: Target : chain:: Access , L :: Target : Logger {
206- event_handler : E ,
207- gossip_sync : & ' a GossipSync < PGS , RGS , G , A , L > ,
208- }
209-
210- impl <
211- ' a ,
212- E : EventHandler ,
213- PGS : Deref < Target = P2PGossipSync < G , A , L > > ,
214- RGS : Deref < Target = RapidGossipSync < G , L > > ,
215- G : Deref < Target = NetworkGraph < L > > ,
216- A : Deref ,
217- L : Deref ,
218- > EventHandler for DecoratingEventHandler < ' a , E , PGS , RGS , G , A , L >
219- where A :: Target : chain:: Access , L :: Target : Logger {
220- fn handle_event ( & self , event : Event ) {
221- if let Some ( network_graph) = self . gossip_sync . network_graph ( ) {
222- if let Event :: PaymentPathFailed { ref network_update, .. } = event {
223- if let Some ( network_update) = network_update {
224- network_graph. handle_network_update ( & network_update) ;
225- }
226- }
227- }
228- self . event_handler . handle_event ( event) ;
229- }
230- }
231-
232195macro_rules! define_run_body {
233196 ( $persister: ident, $chain_monitor: ident, $process_chain_monitor_events: expr,
234197 $channel_manager: ident, $process_channel_manager_events: expr,
@@ -534,9 +497,16 @@ impl BackgroundProcessor {
534497 let stop_thread = Arc :: new ( AtomicBool :: new ( false ) ) ;
535498 let stop_thread_clone = stop_thread. clone ( ) ;
536499 let handle = thread:: spawn ( move || -> Result < ( ) , std:: io:: Error > {
537- let event_handler = DecoratingEventHandler {
538- event_handler,
539- gossip_sync : & gossip_sync,
500+ let event_handler = |event| {
501+ let network_graph = gossip_sync. network_graph ( ) ;
502+ if let Some ( network_graph) = network_graph {
503+ if let Event :: PaymentPathFailed { ref network_update, .. } = event {
504+ if let Some ( network_update) = network_update {
505+ network_graph. handle_network_update ( & network_update) ;
506+ }
507+ }
508+ }
509+ event_handler. handle_event ( event) ;
540510 } ;
541511 define_run_body ! ( persister, chain_monitor, chain_monitor. process_pending_events( & event_handler) ,
542512 channel_manager, channel_manager. process_pending_events( & event_handler) ,
0 commit comments