@@ -165,10 +165,11 @@ impl<'a> Shuttler<'a> {
165165 // Tx Sender for Tx Quene
166166 let ( tx_sender, tx_receiver) = std:: sync:: mpsc:: channel :: < Any > ( ) ;
167167 let conf2 = conf. clone ( ) ;
168+ let identifier2 = identifier. clone ( ) ;
168169 spawn ( async move {
169170 while let Ok ( message) = tx_receiver. recv ( ) {
170- println ! ( "Received: {:?}" , message) ;
171- match send_cosmos_transaction ( & conf2, message) . await {
171+ // println!("Received: {:?}", message);
172+ match send_cosmos_transaction ( & identifier2 , & conf2, message) . await {
172173 Ok ( resp) => {
173174 if let Some ( inner) = resp. into_inner ( ) . tx_response {
174175 debug ! ( "Submited {}, {}, {}" , inner. txhash, inner. code, inner. raw_log)
@@ -179,7 +180,6 @@ impl<'a> Shuttler<'a> {
179180 }
180181 } ) ;
181182
182-
183183 // Common Setting: Context and Heart Beat
184184 let mut context = Context :: new ( swarm, tx_sender, identifier, node_key, conf. clone ( ) ) ;
185185 let mut ticker = tokio:: time:: interval_at ( get_next_full_hour ( ) , Duration :: from_secs ( 5 * 60 ) ) ;
@@ -206,18 +206,31 @@ impl<'a> Shuttler<'a> {
206206
207207 loop {
208208 select ! {
209- Some ( msg) = client. receive_message( ) => {
210- // tracing::info!("msg {:?}", msg);
211- if self . handle_block_event( & mut context, msg) {
212- tracing:: error!( "websocket connection closed, reconnecting..." ) ;
213- tokio:: time:: sleep( Duration :: from_secs( 5 ) ) . await ;
214- if client. reconnect( ) . await . is_err( ) {
215- tracing:: error!( "Failed to reconnect to websocket" ) ;
216- break ;
217- } else {
218- tracing:: info!( "Reconnected to websocket" ) ;
209+ Some ( recv) = client. receive_message( ) => {
210+ match recv {
211+ Ok ( msg) => {
212+ if self . handle_block_event( & mut context, msg) {
213+ tracing:: error!( "websocket connection closed, will reconnect in 5s." ) ;
214+ tokio:: time:: sleep( Duration :: from_secs( 5 ) ) . await ;
215+ if client. reconnect( ) . await . is_err( ) {
216+ tracing:: error!( "Failed to reconnect to websocket" ) ;
217+ break ;
218+ } else {
219+ tracing:: info!( "Reconnected to websocket" ) ;
220+ }
221+ } ;
222+ } ,
223+ Err ( e) => {
224+ tracing:: error!( "websocket error: {:?}, will reconnect in 5s" , e) ;
225+ tokio:: time:: sleep( Duration :: from_secs( 5 ) ) . await ;
226+ if client. reconnect( ) . await . is_err( ) {
227+ tracing:: error!( "Failed to reconnect to websocket" ) ;
228+ break ;
229+ } else {
230+ tracing:: info!( "Reconnected to websocket" ) ;
231+ }
219232 }
220- } ;
233+ }
221234 }
222235 // recv = sidechain_event_stream.next() => {
223236 // match recv {
@@ -248,7 +261,7 @@ impl<'a> Shuttler<'a> {
248261 // info!(" @@(Received) Discovered new peer: {peer_id} with info: {connection_id} {:?}", info);
249262 info. listen_addrs. iter( ) . for_each( |addr| {
250263 if !addr. to_string( ) . starts_with( "/ip4/127.0.0.1" ) {
251- tracing:: debug!( "Discovered: {addr}/p2p/{peer_id}" ) ;
264+ // tracing::debug!("Discovered: {addr}/p2p/{peer_id}");
252265 context. swarm
253266 . behaviour_mut( )
254267 . kad
@@ -276,7 +289,10 @@ impl<'a> Shuttler<'a> {
276289 } else {
277290 let _ = context. swarm. disconnect_peer_id( peer_id) ;
278291 }
279- info!( "Connected peers {:?}" , context. swarm. connected_peers( ) . collect:: <Vec <_>>( ) ) ;
292+
293+ info!( "Connected to {}" , peer_id)
294+
295+ // info!("Connected peers {:?}", context.swarm.connected_peers().map(|i|).collect::<Vec<_>>());
280296 } ,
281297 SwarmEvent :: ConnectionClosed { peer_id, cause, .. } => {
282298 info!( "Disconnected {peer_id}: {:?}" , cause) ;
@@ -336,7 +352,7 @@ impl<'a> Shuttler<'a> {
336352 } ,
337353 tokio_tungstenite:: tungstenite:: Message :: Close ( _close) => {
338354 tracing:: error!( "connection closed" ) ;
339- return false
355+ return true
340356 } ,
341357 _ => return false
342358 } ;
@@ -350,7 +366,7 @@ impl<'a> Shuttler<'a> {
350366 tendermint_rpc:: event:: v0_38:: DeEventData :: NewBlock { block, result_finalize_block , ..} => {
351367 if let Some ( b) = block {
352368 let height = b. header . height . value ( ) ;
353- debug ! ( "Received New block : #{:?}, {:?}" , height, mem_store:: alive_participants_monikers ( ) ) ;
369+ debug ! ( "Block : #{:?}, offline: {:?}" , height, mem_store:: offline_participants_monikers ( ) ) ;
354370 sending_heart_beat ( ctx, height) ;
355371 }
356372 if let Some ( finalize_block) = result_finalize_block {
@@ -420,8 +436,7 @@ impl<'a> Shuttler<'a> {
420436 tasks. push ( task) ;
421437 }
422438 } ;
423- } ) ;
424-
439+ } ) ;
425440 }
426441
427442 if let Some ( lending) = self . apps . iter ( ) . find ( |a| a. name ( ) == APP_NAME_LENDING ) {
0 commit comments