Create basic structure of mempool network adapter for da sampling (#683)

* Create basic structure of mempool network adapter for da sampling

* Return blob instead from sample method

* fmt
This commit is contained in:
Daniel Sanchez 2024-07-26 08:49:24 +00:00 committed by GitHub
parent b9efe1f1ba
commit 91d3558cb2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 38 additions and 3 deletions

View File

@ -1,5 +1,5 @@
[package]
name = "nomos-da-core"
name = "nomos-da-network-core"
version = "0.1.0"
edition = "2021"

View File

@ -2,3 +2,5 @@ pub mod dispersal;
pub mod protocol;
pub mod replication;
pub mod sampling;
pub type SubnetworkId = u32;

View File

@ -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<ReplicationEvent, BehaviourEventToHandler>;
/// Nomos DA BroadcastEvents to be bubble up to logic layers

View File

@ -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" }

View File

@ -1,2 +1,3 @@
mod network;
pub mod service;
pub mod verify;

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@
mod libp2p;

View File

@ -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<<NetworkService<Self::Backend> as ServiceData>::Message>,
network_relay: PhantomData<()>,
) -> Self;
async fn sample(&self, blob_id: &[u8], subnetwork_id: SubnetworkId) -> Option<DaBlob>;
}