diff --git a/nomos-services/consensus/src/lib.rs b/nomos-services/consensus/src/lib.rs index 2bc49f8d..fbdd3d63 100644 --- a/nomos-services/consensus/src/lib.rs +++ b/nomos-services/consensus/src/lib.rs @@ -19,7 +19,7 @@ use leadership::{Leadership, LeadershipResult}; use nomos_core::block::Block; use nomos_core::crypto::PublicKey; use nomos_core::staking::Stake; -use nomos_mempool::{backend::Pool, Mempool}; +use nomos_mempool::{backend::MemPool, network::NetworkAdapter as MempoolAdapter, MempoolService}; use nomos_network::NetworkService; use overlay::{Member, Overlay}; use overwatch_rs::services::relay::{OutboundRelay, Relay}; @@ -43,26 +43,30 @@ pub struct CarnotSettings { private_key: [u8; 32], } -pub struct CarnotConsensus +pub struct CarnotConsensus where A: NetworkAdapter + Send + Sync + 'static, - P: Pool + Send + Sync + 'static, + P: MemPool + Send + Sync + 'static, + P::Settings: Clone + Send + Sync + 'static, P::Tx: Debug + Send + Sync + 'static, P::Id: Debug + Send + Sync + 'static, + M: MempoolAdapter + Send + Sync + 'static, { service_state: ServiceStateHandle, // underlying networking backend. We need this so we can relay and check the types properly // when implementing ServiceCore for CarnotConsensus network_relay: Relay>, - mempool_relay: Relay>, + mempool_relay: Relay>, } -impl ServiceData for CarnotConsensus +impl ServiceData for CarnotConsensus where A: NetworkAdapter + Send + Sync + 'static, - P: Pool + Send + Sync + 'static, + P: MemPool + Send + Sync + 'static, + P::Settings: Clone + Send + Sync + 'static, P::Tx: Debug + Send + Sync + 'static, P::Id: Debug + Send + Sync + 'static, + M: MempoolAdapter + Send + Sync + 'static, { const SERVICE_ID: ServiceId = "Carnot"; type Settings = CarnotSettings; @@ -72,12 +76,14 @@ where } #[async_trait::async_trait] -impl ServiceCore for CarnotConsensus +impl ServiceCore for CarnotConsensus where A: NetworkAdapter + Send + Sync + 'static, - P: Pool + Send + Sync + 'static, + P: MemPool + Send + Sync + 'static, + P::Settings: Clone + Send + Sync + 'static, P::Tx: Debug + Send + Sync + 'static, P::Id: Debug + Send + Sync + 'static, + M: MempoolAdapter + Send + Sync + 'static, { fn init(service_state: ServiceStateHandle) -> Result { let network_relay = service_state.overwatch_handle.relay(); @@ -102,7 +108,7 @@ where .mempool_relay .connect() .await - .expect("Relay connection with MempoolService should succeed"); + .expect("Relay connection with MemPoolService should succeed"); let network_adapter = A::new(network_relay).await; @@ -133,12 +139,14 @@ where } } -impl CarnotConsensus +impl CarnotConsensus where A: NetworkAdapter + Send + Sync + 'static, - P: Pool + Send + Sync + 'static, + P: MemPool + Send + Sync + 'static, + P::Settings: Clone + Send + Sync + 'static, P::Tx: Debug + Send + Sync + 'static, P::Id: Debug + Send + Sync + 'static, + M: MempoolAdapter + Send + Sync + 'static, { // Build a service that generates new views as they become available async fn view_generator(&self) -> ViewGenerator {