@@ -38,6 +38,8 @@ use lightning::routing::router::Router;
3838use  lightning:: routing:: scoring:: { Score ,  WriteableScore } ; 
3939use  lightning:: util:: logger:: Logger ; 
4040use  lightning:: util:: persist:: Persister ; 
41+ #[ cfg( feature = "std" ) ]  
42+ use  lightning:: util:: wakers:: Sleeper ; 
4143use  lightning_rapid_gossip_sync:: RapidGossipSync ; 
4244
4345use  core:: ops:: Deref ; 
@@ -388,23 +390,32 @@ pub(crate) mod futures_util {
388390	use  core:: task:: { Poll ,  Waker ,  RawWaker ,  RawWakerVTable } ; 
389391	use  core:: pin:: Pin ; 
390392	use  core:: marker:: Unpin ; 
391- 	pub ( crate )  struct  Selector < A :  Future < Output =( ) >  + Unpin ,  B :  Future < Output =bool >  + Unpin >  { 
393+ 	pub ( crate )  struct  Selector < 
394+ 		A :  Future < Output =( ) >  + Unpin ,  B :  Future < Output =( ) >  + Unpin ,  C :  Future < Output =bool >  + Unpin 
395+ 	>  { 
392396		pub  a :  A , 
393397		pub  b :  B , 
398+ 		pub  c :  C , 
394399	} 
395400	pub ( crate )  enum  SelectorOutput  { 
396- 		A ,  B ( bool ) , 
401+ 		A ,  B ,   C ( bool ) , 
397402	} 
398403
399- 	impl < A :  Future < Output =( ) >  + Unpin ,  B :  Future < Output =bool >  + Unpin >  Future  for  Selector < A ,  B >  { 
404+ 	impl < 
405+ 		A :  Future < Output =( ) >  + Unpin ,  B :  Future < Output =( ) >  + Unpin ,  C :  Future < Output =bool >  + Unpin 
406+ 	>  Future  for  Selector < A ,  B ,  C >  { 
400407		type  Output  = SelectorOutput ; 
401408		fn  poll ( mut  self :  Pin < & mut  Self > ,  ctx :  & mut  core:: task:: Context < ' _ > )  -> Poll < SelectorOutput >  { 
402409			match  Pin :: new ( & mut  self . a ) . poll ( ctx)  { 
403410				Poll :: Ready ( ( ) )  => {  return  Poll :: Ready ( SelectorOutput :: A ) ;  } , 
404411				Poll :: Pending  => { } , 
405412			} 
406413			match  Pin :: new ( & mut  self . b ) . poll ( ctx)  { 
407- 				Poll :: Ready ( res)  => {  return  Poll :: Ready ( SelectorOutput :: B ( res) ) ;  } , 
414+ 				Poll :: Ready ( ( ) )  => {  return  Poll :: Ready ( SelectorOutput :: B ) ;  } , 
415+ 				Poll :: Pending  => { } , 
416+ 			} 
417+ 			match  Pin :: new ( & mut  self . c ) . poll ( ctx)  { 
418+ 				Poll :: Ready ( res)  => {  return  Poll :: Ready ( SelectorOutput :: C ( res) ) ;  } , 
408419				Poll :: Pending  => { } , 
409420			} 
410421			Poll :: Pending 
@@ -514,11 +525,13 @@ where
514525		gossip_sync,  peer_manager,  logger,  scorer,  should_break,  { 
515526			let  fut = Selector  { 
516527				a:  channel_manager. get_persistable_update_future( ) , 
517- 				b:  sleeper( Duration :: from_millis( 100 ) ) , 
528+ 				b:  chain_monitor. get_update_future( ) , 
529+ 				c:  sleeper( Duration :: from_millis( 100 ) ) , 
518530			} ; 
519531			match  fut. await  { 
520532				SelectorOutput :: A  => true , 
521- 				SelectorOutput :: B ( exit)  => { 
533+ 				SelectorOutput :: B  => false , 
534+ 				SelectorOutput :: C ( exit)  => { 
522535					should_break = exit; 
523536					false 
524537				} 
@@ -643,7 +656,10 @@ impl BackgroundProcessor {
643656			define_run_body ! ( persister,  chain_monitor,  chain_monitor. process_pending_events( & event_handler) , 
644657				channel_manager,  channel_manager. process_pending_events( & event_handler) , 
645658				gossip_sync,  peer_manager,  logger,  scorer,  stop_thread. load( Ordering :: Acquire ) , 
646- 				channel_manager. get_persistable_update_future( ) . wait_timeout( Duration :: from_millis( 100 ) ) , 
659+ 				Sleeper :: from_two_futures( 
660+ 					channel_manager. get_persistable_update_future( ) , 
661+ 					chain_monitor. get_update_future( ) 
662+ 				) . wait_timeout( Duration :: from_millis( 100 ) ) , 
647663				|_| Instant :: now( ) ,  |time:  & Instant ,  dur| time. elapsed( ) . as_secs( )  > dur) 
648664		} ) ; 
649665		Self  {  stop_thread :  stop_thread_clone,  thread_handle :  Some ( handle)  } 
0 commit comments