Add dummy libp2p adapter for mempool (#286)

This commit is contained in:
Giacomo Pasini 2023-08-02 17:00:52 +02:00 committed by GitHub
parent f8422fc7a8
commit 083d061e46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 0 deletions

View File

@ -32,3 +32,4 @@ blake2 = "0.10"
default = []
waku = ["nomos-network/waku", "nomos-core/waku", "waku-bindings"]
mock = ["linked-hash-map", "nomos-network/mock", "rand", "nomos-core/mock"]
libp2p = ["nomos-network/libp2p"]

View File

@ -0,0 +1,38 @@
// std
use std::marker::PhantomData;
// crates
use futures::Stream;
use serde::{de::DeserializeOwned, Serialize};
// internal
use crate::network::NetworkAdapter;
use nomos_network::backends::libp2p::Libp2p;
use nomos_network::NetworkService;
use overwatch_rs::services::relay::OutboundRelay;
use overwatch_rs::services::ServiceData;
pub struct Libp2pAdapter<Tx> {
_network_relay: OutboundRelay<<NetworkService<Libp2p> as ServiceData>::Message>,
_tx: PhantomData<Tx>,
}
#[async_trait::async_trait]
impl<Tx> NetworkAdapter for Libp2pAdapter<Tx>
where
Tx: DeserializeOwned + Serialize + Send + Sync + 'static,
{
type Backend = Libp2p;
type Tx = Tx;
async fn new(
_network_relay: OutboundRelay<<NetworkService<Self::Backend> as ServiceData>::Message>,
) -> Self {
Self {
_network_relay,
_tx: PhantomData,
}
}
async fn transactions_stream(&self) -> Box<dyn Stream<Item = Self::Tx> + Unpin + Send> {
// TODO
Box::new(futures::stream::empty())
}
}

View File

@ -1,5 +1,8 @@
#[cfg(feature = "waku")]
pub mod waku;
#[cfg(feature = "libp2p")]
pub mod libp2p;
#[cfg(feature = "mock")]
pub mod mock;