File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
crates/op-rbuilder/src/builders/flashblocks Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ use core::{
66 task:: { Context , Poll } ,
77} ;
88use futures:: { Sink , SinkExt } ;
9+ use futures_util:: StreamExt ;
910use rollup_boost:: FlashblocksPayloadV1 ;
1011use std:: { io, net:: TcpListener , sync:: Arc } ;
1112use tokio:: {
@@ -209,6 +210,30 @@ async fn broadcast_loop(
209210 tracing:: warn!( "Broadcast channel lagged, some messages were dropped" ) ;
210211 }
211212 } ,
213+
214+ // This handles channel closing and ping-pong logic
215+ message = stream. next( ) => if let Some ( message) = message { match message {
216+ Ok ( message) => {
217+ match message {
218+ Message :: Ping ( data) => {
219+ if let Err ( e) = stream. send( Message :: Pong ( data) ) . await {
220+ tracing:: warn!( "Closing flashblocks subscription for {peer_addr}: {e}" ) ;
221+ break ; // Exit the loop if sending fails
222+ }
223+ }
224+ // We don't get any data from RB, so we won't handle closing frame
225+ Message :: Close ( _) => {
226+ tracing:: info!( "Closing frame received, stopping connection for {peer_addr}" ) ;
227+ break ;
228+ }
229+ _ => ( ) ,
230+ }
231+ }
232+ Err ( e) => {
233+ tracing:: warn!( "Received error. Closing flashblocks subscription for {peer_addr}: {e}" ) ;
234+ break ;
235+ }
236+ } }
212237 }
213238 }
214239}
You can’t perform that action at this time.
0 commit comments