diff --git a/crates/sui-node/src/lib.rs b/crates/sui-node/src/lib.rs index a4878e21a6641..df5812084bd97 100644 --- a/crates/sui-node/src/lib.rs +++ b/crates/sui-node/src/lib.rs @@ -153,7 +153,7 @@ mod handle; pub mod metrics; pub struct ValidatorComponents { - validator_server_handle: ValidatorGrpcServerHandle, + validator_server_handle: SpawnOnce, validator_overload_monitor_handle: Option>, consensus_manager: ConsensusManager, consensus_store_pruner: ConsensusStorePruner, @@ -1331,7 +1331,7 @@ impl SuiNode { consensus_store_pruner: ConsensusStorePruner, accumulator: Weak, backpressure_manager: Arc, - validator_server_handle: ValidatorGrpcServerHandle, + validator_server_handle: SpawnOnce, validator_overload_monitor_handle: Option>, checkpoint_metrics: Arc, sui_node_metrics: Arc, @@ -1511,7 +1511,7 @@ impl SuiNode { state: Arc, consensus_adapter: Arc, prometheus_registry: &Registry, - ) -> Result { + ) -> Result { let validator_service = ValidatorService::new( state.clone(), consensus_adapter, @@ -1540,9 +1540,7 @@ impl SuiNode { let local_addr = server.local_addr(); info!("Listening to traffic on {local_addr}"); - Ok(ValidatorGrpcServerHandle::new( - server.serve().map_err(Into::into), - )) + Ok(SpawnOnce::new(server.serve().map_err(Into::into))) } async fn reexecute_pending_consensus_certs( @@ -2051,14 +2049,14 @@ impl SuiNode { } } -enum ValidatorGrpcServerHandle { - // Mutex is only needed to make ValidatorGrpcServerHandle Send +enum SpawnOnce { + // Mutex is only needed to make SpawnOnce Send Unstarted(Mutex>>), #[allow(unused)] Started(JoinHandle>), } -impl ValidatorGrpcServerHandle { +impl SpawnOnce { pub fn new(future: impl Future> + Send + 'static) -> Self { Self::Unstarted(Mutex::new(Box::pin(future))) }