diff --git a/nomos-da/network/core/Cargo.toml b/nomos-da/network/core/Cargo.toml index de403ab5..24382b59 100644 --- a/nomos-da/network/core/Cargo.toml +++ b/nomos-da/network/core/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "nomos-da-core" +name = "nomos-da-network-core" version = "0.1.0" edition = "2021" diff --git a/nomos-da/network/core/src/lib.rs b/nomos-da/network/core/src/lib.rs index 7f8f637f..020672e5 100644 --- a/nomos-da/network/core/src/lib.rs +++ b/nomos-da/network/core/src/lib.rs @@ -2,3 +2,5 @@ pub mod dispersal; pub mod protocol; pub mod replication; pub mod sampling; + +pub type SubnetworkId = u32; diff --git a/nomos-da/network/core/src/replication/behaviour.rs b/nomos-da/network/core/src/replication/behaviour.rs index 3d5b5b0d..abe9e12e 100644 --- a/nomos-da/network/core/src/replication/behaviour.rs +++ b/nomos-da/network/core/src/replication/behaviour.rs @@ -12,12 +12,12 @@ use tracing::error; use subnetworks_assignations::MembershipHandler; +use crate::SubnetworkId; + use super::handler::{ BehaviourEventToHandler, DaMessage, HandlerEventToBehaviour, ReplicationHandler, }; -pub type SubnetworkId = u32; - type SwarmEvent = ToSwarm; /// Nomos DA BroadcastEvents to be bubble up to logic layers diff --git a/nomos-services/mempool/Cargo.toml b/nomos-services/mempool/Cargo.toml index 73fd1915..95c1be9c 100644 --- a/nomos-services/mempool/Cargo.toml +++ b/nomos-services/mempool/Cargo.toml @@ -12,6 +12,7 @@ futures = "0.3" linked-hash-map = { version = "0.5.6", optional = true } nomos-metrics = { path = "../../nomos-services/metrics" } nomos-network = { path = "../network" } +nomos-da-network-core = { path = "../../nomos-da/network/core" } nomos-core = { path = "../../nomos-core" } full-replication = { path = "../../nomos-da/full-replication" } kzgrs-backend = { path = "../../nomos-da/kzgrs-backend" } diff --git a/nomos-services/mempool/src/da/mod.rs b/nomos-services/mempool/src/da/mod.rs index 84ec6fd2..5ae272a2 100644 --- a/nomos-services/mempool/src/da/mod.rs +++ b/nomos-services/mempool/src/da/mod.rs @@ -1,2 +1,3 @@ +mod network; pub mod service; pub mod verify; diff --git a/nomos-services/mempool/src/da/network/adapters/libp2p.rs b/nomos-services/mempool/src/da/network/adapters/libp2p.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/nomos-services/mempool/src/da/network/adapters/libp2p.rs @@ -0,0 +1 @@ + diff --git a/nomos-services/mempool/src/da/network/adapters/mod.rs b/nomos-services/mempool/src/da/network/adapters/mod.rs new file mode 100644 index 00000000..a44e1e31 --- /dev/null +++ b/nomos-services/mempool/src/da/network/adapters/mod.rs @@ -0,0 +1 @@ +mod libp2p; diff --git a/nomos-services/mempool/src/da/network/mod.rs b/nomos-services/mempool/src/da/network/mod.rs new file mode 100644 index 00000000..c8c10282 --- /dev/null +++ b/nomos-services/mempool/src/da/network/mod.rs @@ -0,0 +1,29 @@ +use std::marker::PhantomData; + +use kzgrs_backend::common::blob::DaBlob; +// crates +use nomos_da_network_core::SubnetworkId; + +// internal +pub mod adapters; +// std + +// TODO: remove after using it in the service +#[allow(dead_code)] +#[async_trait::async_trait] +pub trait DaNetworkAdapter { + // TODO: bound to proper da-backend trait + type Backend; + type Settings: Clone; + type Payload: Send + Sync + 'static; + type Key: Send + Sync + 'static; + + async fn new( + settings: Self::Settings, + // TODO: hook da-network service instead of network service + // network_relay: OutboundRelay< as ServiceData>::Message>, + network_relay: PhantomData<()>, + ) -> Self; + + async fn sample(&self, blob_id: &[u8], subnetwork_id: SubnetworkId) -> Option; +}