6868 ///
6969 /// This is the sole network message receiver to prevent race conditions.
7070 /// All sync operations coordinate through this monitoring loop.
71- pub async fn run (
71+ pub async fn monitor_network (
7272 & mut self ,
73- mut receiver : UnboundedReceiver < DashSpvClientCommand > ,
73+ mut command_receiver : UnboundedReceiver < DashSpvClientCommand > ,
7474 token : CancellationToken ,
7575 ) -> Result < ( ) > {
7676 let running = self . running . read ( ) . await ;
@@ -482,7 +482,7 @@ impl<
482482 }
483483
484484 tokio:: select! {
485- received = receiver . recv( ) => {
485+ received = command_receiver . recv( ) => {
486486 match received {
487487 None => { tracing:: warn!( "DashSpvClientCommand channel closed." ) ; } ,
488488 Some ( command) => {
@@ -570,15 +570,15 @@ impl<
570570 Ok ( ( ) )
571571 }
572572
573- pub async fn run_until_shutdown (
573+ pub async fn run (
574574 mut self ,
575- receiver : UnboundedReceiver < DashSpvClientCommand > ,
575+ command_receiver : UnboundedReceiver < DashSpvClientCommand > ,
576576 shutdown_token : CancellationToken ,
577577 ) -> Result < ( ) > {
578578 let client_token = shutdown_token. clone ( ) ;
579579
580580 let client_task = tokio:: spawn ( async move {
581- let result = self . run ( receiver , client_token) . await ;
581+ let result = self . monitor_network ( command_receiver , client_token) . await ;
582582 if let Err ( e) = & result {
583583 tracing:: error!( "Error running client: {}" , e) ;
584584 }
@@ -589,7 +589,9 @@ impl<
589589 } ) ;
590590
591591 let shutdown_task = tokio:: spawn ( async move {
592- let _ = tokio:: signal:: ctrl_c ( ) . await ;
592+ if let Err ( e) = tokio:: signal:: ctrl_c ( ) . await {
593+ tracing:: error!( "Error waiting for ctrl_c: {}" , e) ;
594+ }
593595 tracing:: debug!( "Shutdown signal received" ) ;
594596 shutdown_token. cancel ( ) ;
595597 } ) ;
0 commit comments