@@ -22,7 +22,7 @@ use once_cell::sync::Lazy;
2222use serde_json:: { json, Value } ;
2323use std:: { collections:: HashSet , error:: Error , time:: Duration } ;
2424use tokio:: sync:: Mutex ;
25- use tracing:: { error, info} ;
25+ use tracing:: { error, info, warn } ;
2626
2727pub const TEST_BOOSTNODE_PEER_ID_LIST : [ & str ; 3 ] = [
2828 "16Uiu2HAm5SPUotukayoKUZG5jQQ9zAGgjAXXz4Tg62kzZMbikLdQ" ,
@@ -76,6 +76,7 @@ impl EventLoop {
7676 pub ( crate ) async fn run ( & mut self ) {
7777 let mut interval1 = tokio:: time:: interval ( tokio:: time:: Duration :: from_secs ( 60 ) ) ;
7878 let mut interval2 = tokio:: time:: interval ( tokio:: time:: Duration :: from_secs ( 60 ) ) ;
79+ let mut interval3 = tokio:: time:: interval ( tokio:: time:: Duration :: from_secs ( 60 ) ) ;
7980 loop {
8081 tokio:: select! {
8182 event = self . swarm. select_next_some( ) => self . handle_event( event) . await ,
@@ -91,6 +92,10 @@ impl EventLoop {
9192 }
9293 info!( "\n ------ 60 secs, local_peer_id is {:?}, swarm peer list is {:?}\n \n " , self . swarm. local_peer_id( ) , peer_list) ;
9394 }
95+
96+ _ = interval3. tick( ) => {
97+ info!( "------ 60 secs, Listeners: {:?}" , self . swarm. listeners( ) . collect:: <Vec <_>>( ) ) ;
98+ }
9499 }
95100 }
96101 }
@@ -111,6 +116,28 @@ impl EventLoop {
111116 _ = self . swarm . disconnect_peer_id ( peer_id) ;
112117 }
113118 }
119+ SwarmEvent :: ListenerClosed {
120+ reason,
121+ addresses,
122+ listener_id,
123+ } => {
124+ warn ! (
125+ "Listener closed: {:?}, addresses: {:?}, listener_id is {:?}" ,
126+ reason, addresses, listener_id
127+ ) ;
128+ for addr in addresses {
129+ warn ! ( "Attempting to re-listen on: {:?}" , addr) ;
130+ if let Err ( e) = self . swarm . listen_on ( addr. clone ( ) ) {
131+ warn ! ( "Failed to re-listen on {:?}: {:?}" , addr, e) ;
132+ }
133+ }
134+ }
135+ SwarmEvent :: ListenerError { error, listener_id } => {
136+ warn ! (
137+ "Listener error: {:?}, listener_id: {:?}" ,
138+ error, listener_id
139+ ) ;
140+ }
114141 SwarmEvent :: Behaviour ( AgentEvent :: Identify ( sub_event) ) => {
115142 self . handle_identify_event ( sub_event) . await
116143 }
0 commit comments