@@ -17,10 +17,12 @@ use pathfinder_ethereum::EthereumClient;
1717use pathfinder_gas_price:: { L1GasPriceConfig , L1GasPriceProvider } ;
1818#[ cfg( feature = "p2p" ) ]
1919use pathfinder_lib:: consensus:: ConsensusTaskHandles ;
20+ #[ cfg( feature = "p2p" ) ]
21+ use pathfinder_lib:: preconfirmed:: PreconfirmedTaskHandles ;
2022use pathfinder_lib:: state:: { sync_gas_prices, L1GasPriceSyncConfig , SyncContext } ;
2123use pathfinder_lib:: ConsensusChannels ;
2224#[ cfg( feature = "p2p" ) ]
23- use pathfinder_lib:: { config, consensus, monitoring, p2p_network, state} ;
25+ use pathfinder_lib:: { config, consensus, monitoring, p2p_network, preconfirmed , state} ;
2426#[ cfg( not( feature = "p2p" ) ) ]
2527use pathfinder_lib:: { config, monitoring, p2p_network, state} ;
2628use pathfinder_rpc:: context:: { EthContractAddresses , WebsocketContext } ;
@@ -323,7 +325,7 @@ Hint: This is usually caused by exceeding the file descriptor limit of your syst
323325 )
324326 . await ;
325327
326- let ( preconfirmed_p2p_handle, _preconfirmed_p2p_client_and_event_rx ) =
328+ let ( preconfirmed_p2p_handle, preconfirmed_p2p_client_and_event_rx ) =
327329 if config. preconfirmed_p2p . enable {
328330 p2p_network:: preconfirmed:: start (
329331 chain_id,
@@ -437,13 +439,41 @@ Hint: This is usually caused by exceeding the file descriptor limit of your syst
437439 )
438440 } ;
439441
440- let context = if let Some ( consensus_info_watch) = consensus_channels
442+ #[ cfg( feature = "p2p" ) ]
443+ let ( preconfirmed_p2p_event_processing_handle, preconfirmed_watch_rx) = {
444+ let handles = if config. preconfirmed_p2p . enable {
445+ match preconfirmed_p2p_client_and_event_rx {
446+ Some ( ( event_rx, _) ) => preconfirmed:: start ( event_rx) ,
447+ None => PreconfirmedTaskHandles :: pending ( ) ,
448+ }
449+ } else {
450+ PreconfirmedTaskHandles :: pending ( )
451+ } ;
452+ (
453+ handles. preconfirmed_p2p_event_processing_handle ,
454+ handles. preconfirmed_watch ,
455+ )
456+ } ;
457+
458+ #[ cfg( not( feature = "p2p" ) ) ]
459+ let ( preconfirmed_p2p_event_processing_handle, preconfirmed_watch_rx) = {
460+ let _ = preconfirmed_p2p_client_and_event_rx;
461+ (
462+ tokio:: task:: spawn ( std:: future:: pending :: < anyhow:: Result < ( ) > > ( ) ) ,
463+ None ,
464+ )
465+ } ;
466+
467+ let context = match consensus_channels
441468 . as_ref ( )
442469 . map ( |cc| cc. consensus_info_watch . clone ( ) )
443470 {
444- context. with_consensus_info_watch ( consensus_info_watch)
445- } else {
446- context
471+ Some ( consensus_info_watch) => context. with_consensus_info_watch ( consensus_info_watch) ,
472+ None => context,
473+ } ;
474+ let context = match preconfirmed_watch_rx {
475+ Some ( preconfirmed_watch) => context. with_preconfirmed_watch ( preconfirmed_watch) ,
476+ None => context,
447477 } ;
448478
449479 let default_version = match config. rpc_root_version {
@@ -528,6 +558,7 @@ Hint: This is usually caused by exceeding the file descriptor limit of your syst
528558 result = consensus_p2p_handle => handle_critical_task_result( "Consensus P2P network" , result) ,
529559 result = preconfirmed_p2p_handle => handle_critical_task_result( "Preconfirmed P2P network" , result) ,
530560 result = consensus_p2p_event_processing_handle => handle_critical_task_result( "Consensus P2P event processing" , result) ,
561+ result = preconfirmed_p2p_event_processing_handle => handle_critical_task_result( "Preconfirmed P2P event processing" , result) ,
531562 result = consensus_engine_handle => handle_critical_task_result( "Consensus engine" , result) ,
532563 result = http_client_refresh_handle => handle_critical_task_result( "HTTP client refresh" , result) ,
533564 _ = term_signal. recv( ) => {
0 commit comments