@@ -22,9 +22,8 @@ use crate::{
2222} ;
2323
2424mod channel_pool;
25- mod error;
26- mod join_set;
27- mod mailbox;
25+ pub ( crate ) mod error;
26+ pub ( crate ) mod mailbox;
2827pub mod message;
2928mod request_queue;
3029mod task;
@@ -316,6 +315,8 @@ impl PeerConnectionStatus {
316315/// Connection killed on drop
317316pub struct ConnectionHandle {
318317 task : JoinHandle < ( ) > ,
318+ /// Indicates that at least one message has been received successfully
319+ pub ( in crate :: net) received_msg_successfully : Arc < AtomicBool > ,
319320 /// Representation of [`PeerConnectionStatus`]
320321 pub ( in crate :: net) status_repr : Arc < AtomicBool > ,
321322 /// Push messages from connection task / net task / node
@@ -328,6 +329,12 @@ impl ConnectionHandle {
328329 self . status_repr . load ( atomic:: Ordering :: SeqCst ) ,
329330 )
330331 }
332+
333+ /// Indicates that at least one message has been received successfully
334+ pub fn received_msg_successfully ( & self ) -> bool {
335+ self . received_msg_successfully
336+ . load ( atomic:: Ordering :: SeqCst )
337+ }
331338}
332339
333340impl Drop for ConnectionHandle {
@@ -346,15 +353,18 @@ pub fn handle(
346353 let ( info_tx, info_rx) = mpsc:: unbounded ( ) ;
347354 let ( mailbox_tx, mailbox_rx) = mailbox:: new ( ) ;
348355 let internal_message_tx = mailbox_tx. internal_message_tx . clone ( ) ;
356+ let received_msg_successfully = Arc :: new ( AtomicBool :: new ( false ) ) ;
349357 let connection_task = {
350358 let info_tx = info_tx. clone ( ) ;
359+ let received_msg_successfully = received_msg_successfully. clone ( ) ;
351360 move || async move {
352361 let connection_task = ConnectionTask {
353362 connection,
354363 ctxt,
355364 info_tx,
356365 mailbox_rx,
357366 mailbox_tx,
367+ received_msg_successfully,
358368 } ;
359369 connection_task. run ( ) . await
360370 }
@@ -373,6 +383,7 @@ pub fn handle(
373383 let status = PeerConnectionStatus :: Connected ;
374384 let connection_handle = ConnectionHandle {
375385 task,
386+ received_msg_successfully,
376387 status_repr : Arc :: new ( AtomicBool :: new ( status. as_repr ( ) ) ) ,
377388 internal_message_tx,
378389 } ;
@@ -385,10 +396,12 @@ pub fn connect(
385396) -> ( ConnectionHandle , mpsc:: UnboundedReceiver < Info > ) {
386397 let connection_status = PeerConnectionStatus :: Connecting ;
387398 let status_repr = Arc :: new ( AtomicBool :: new ( connection_status. as_repr ( ) ) ) ;
399+ let received_msg_successfully = Arc :: new ( AtomicBool :: new ( false ) ) ;
388400 let ( info_tx, info_rx) = mpsc:: unbounded ( ) ;
389401 let ( mailbox_tx, mailbox_rx) = mailbox:: new ( ) ;
390402 let internal_message_tx = mailbox_tx. internal_message_tx . clone ( ) ;
391403 let connection_task = {
404+ let received_msg_successfully = received_msg_successfully. clone ( ) ;
392405 let status_repr = status_repr. clone ( ) ;
393406 let info_tx = info_tx. clone ( ) ;
394407 move || async move {
@@ -404,6 +417,7 @@ pub fn connect(
404417 info_tx,
405418 mailbox_rx,
406419 mailbox_tx,
420+ received_msg_successfully,
407421 } ;
408422 connection_task. run ( ) . await
409423 }
@@ -419,6 +433,7 @@ pub fn connect(
419433 } ) ;
420434 let connection_handle = ConnectionHandle {
421435 task,
436+ received_msg_successfully,
422437 status_repr,
423438 internal_message_tx,
424439 } ;
0 commit comments