@@ -4,7 +4,7 @@ use anyhow::Result;
4
4
use bytes:: { Buf , Bytes } ;
5
5
use futures:: { SinkExt , StreamExt } ;
6
6
use lightning_interfaces:: types:: NodeIndex ;
7
- use lightning_interfaces:: { RequestHeader , ServiceScope } ;
7
+ use lightning_interfaces:: { spawn , RequestHeader , ServiceScope } ;
8
8
use tokio:: io:: { AsyncReadExt , AsyncWriteExt } ;
9
9
use tokio:: sync:: mpsc:: { Receiver , Sender } ;
10
10
use tokio:: sync:: oneshot;
@@ -57,7 +57,7 @@ pub async fn connection_loop<C: ConnectionInterface>(mut ctx: Context<C>) -> Res
57
57
} ;
58
58
let connection_event_tx = ctx. connection_event_tx. clone( ) ;
59
59
let peer = ctx. peer;
60
- tokio :: spawn( async move {
60
+ spawn! ( async move {
61
61
if let Err ( e) =
62
62
handle_incoming_bi_stream:: <C >(
63
63
peer,
@@ -69,7 +69,7 @@ pub async fn connection_loop<C: ConnectionInterface>(mut ctx: Context<C>) -> Res
69
69
"failed to handle incoming bi-stream with peer with index {peer}: {e:?}"
70
70
) ;
71
71
}
72
- } ) ;
72
+ } , "POOL: handle incoming bi stream" ) ;
73
73
}
74
74
accept_result = connection. accept_uni_stream( ) => {
75
75
let stream_rx = match accept_result {
@@ -80,7 +80,7 @@ pub async fn connection_loop<C: ConnectionInterface>(mut ctx: Context<C>) -> Res
80
80
} ;
81
81
let connection_event_tx = ctx. connection_event_tx. clone( ) ;
82
82
let peer = ctx. peer;
83
- tokio :: spawn( async move {
83
+ spawn! ( async move {
84
84
if let Err ( e) =
85
85
handle_incoming_uni_stream:: <C >(
86
86
peer,
@@ -92,7 +92,7 @@ pub async fn connection_loop<C: ConnectionInterface>(mut ctx: Context<C>) -> Res
92
92
"failed to handle incoming uni-stream from peer with index {peer}: {e:?}"
93
93
) ;
94
94
}
95
- } ) ;
95
+ } , "POOL: handle incoming uni stream" ) ;
96
96
}
97
97
request = ctx. service_request_rx. recv( ) => {
98
98
match request {
@@ -101,20 +101,20 @@ pub async fn connection_loop<C: ConnectionInterface>(mut ctx: Context<C>) -> Res
101
101
// We need to create a new stream on the connection.
102
102
let connection = ctx. connection. clone( ) ;
103
103
let peer = ctx. peer;
104
- tokio :: spawn( async move{
104
+ spawn! ( async move{
105
105
if let Err ( e) = send_message( connection, message) . await {
106
106
tracing:: error!(
107
107
"failed to send message to peer with index {peer}: {e:?}"
108
108
) ;
109
109
}
110
- } ) ;
110
+ } , "POOL: send message" ) ;
111
111
} ,
112
112
Some ( Request :: SendReqResp { service, request, respond } ) => {
113
113
tracing:: trace!( "handling new outgoing request" ) ;
114
114
// We need to create a new stream on the connection for the channel.
115
115
let connection = ctx. connection. clone( ) ;
116
116
let peer = ctx. peer;
117
- tokio :: spawn( async move {
117
+ spawn! ( async move {
118
118
if let Err ( e) = send_request(
119
119
connection,
120
120
service,
@@ -125,7 +125,7 @@ pub async fn connection_loop<C: ConnectionInterface>(mut ctx: Context<C>) -> Res
125
125
"there was an error when sending request to {peer}: {e:?}"
126
126
) ;
127
127
}
128
- } ) ;
128
+ } , "POOL: send request" ) ;
129
129
}
130
130
Some ( Request :: Stats { respond } ) => {
131
131
tracing:: debug!( "handling new stats request" ) ;
0 commit comments