This commit is contained in:
Al Liu 2024-01-18 13:41:35 +08:00
parent 9460071d59
commit dbc5a0890a
No known key found for this signature in database
GPG Key ID: C8AE9A6E0166923E
11 changed files with 14 additions and 29 deletions

View File

@ -61,7 +61,6 @@ pub struct AxumBackend<T, S, const SIZE: usize> {
)]
struct ApiDoc;
#[async_trait::async_trait]
impl<T, S, const SIZE: usize> Backend for AxumBackend<T, S, SIZE>
where
T: Transaction

View File

@ -7,8 +7,6 @@ use carnot_engine::overlay::{RandomBeaconState, RoundRobin, TreeOverlay};
use color_eyre::eyre::Result;
use full_replication::Certificate;
use full_replication::{AbsoluteNumber, Attestation, Blob, FullReplication};
#[cfg(feature = "metrics")]
use metrics::{backend::map::MapMetricsBackend, types::MetricsData, MetricsService};
use api::AxumBackend;
use bytes::Bytes;
@ -46,8 +44,7 @@ use nomos_core::{
};
use nomos_network::NetworkService;
use nomos_system_sig::SystemSig;
use overwatch_derive::*;
use overwatch_rs::services::handle::ServiceHandle;
use overwatch_rs::{services::handle::ServiceHandle, Services};
use serde::{de::DeserializeOwned, Serialize};
pub use tx::Tx;

View File

@ -7,7 +7,6 @@ use nomos_core::{da::DaProtocol, wire};
use nomos_da::network::{adapters::libp2p::Libp2pAdapter, NetworkAdapter};
use nomos_log::Logger;
use nomos_network::{backends::libp2p::Libp2p, NetworkService};
use overwatch_derive::*;
use overwatch_rs::{
services::{
handle::{ServiceHandle, ServiceStateHandle},
@ -15,7 +14,7 @@ use overwatch_rs::{
state::*,
ServiceCore, ServiceData, ServiceId,
},
DynError,
DynError, Services,
};
use reqwest::Url;
use serde::Serialize;
@ -139,7 +138,6 @@ impl ServiceData for DisseminateService {
type Message = NoMessage;
}
#[async_trait::async_trait]
impl ServiceCore for DisseminateService {
fn init(service_state: ServiceStateHandle<Self>) -> Result<Self, DynError> {
Ok(Self { service_state })

View File

@ -82,7 +82,7 @@ impl ServiceCore for Metrics {
let reg = registry.lock().unwrap();
// If encoding fails, we need to stop trying process subsequent metrics gather
// requests. If it succeds, encode method returns empty unit type.
_ = encode(&mut buf, &reg).map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
encode(&mut buf, &reg).map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
}
reply_channel

View File

@ -15,7 +15,7 @@ where
N: NetworkBackend,
A: NetworkAdapter<Backend = N, Item = Item, Key = Key> + Send + Sync + 'static,
A::Settings: Send + Sync,
D: Discriminant,
D: Discriminant + Send,
Item: Clone + Debug + Send + Sync + 'static + Hash,
Key: Clone + Debug + Ord + Hash + 'static,
{

View File

@ -8,21 +8,22 @@ use overwatch_rs::{
},
DynError,
};
use std::future::Future;
pub mod http;
/// A simple abstraction so that we can easily
/// change the underlying http server
#[async_trait::async_trait]
pub trait Backend {
type Error: std::error::Error + Send + Sync + 'static;
type Settings: Clone + Send + Sync + 'static;
async fn new(settings: Self::Settings) -> Result<Self, Self::Error>
fn new(settings: Self::Settings) -> impl Future<Output = Result<Self, Self::Error>> + Send
where
Self: Sized;
async fn serve(self, handle: OverwatchHandle) -> Result<(), Self::Error>;
fn serve(self, handle: OverwatchHandle)
-> impl Future<Output = Result<(), Self::Error>> + Send;
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
@ -47,7 +48,6 @@ impl<B: Backend> ServiceData for ApiService<B> {
type Message = NoMessage;
}
#[async_trait::async_trait]
impl<B> ServiceCore for ApiService<B>
where
B: Backend + Send + Sync + 'static,
@ -62,7 +62,7 @@ where
}
/// Service main loop
async fn run(mut self) -> Result<(), DynError> {
async fn run(self) -> Result<(), DynError> {
let endpoint = B::new(self.settings.backend_settings).await?;
endpoint.serve(self.handle).await?;
Ok(())

View File

@ -7,10 +7,10 @@ use std::{
use axum::{routing, Router, Server};
use hyper::Error;
use nomos_api::{ApiService, ApiServiceSettings, Backend};
use overwatch_derive::Services;
use overwatch_rs::{
overwatch::{handle::OverwatchHandle, OverwatchRunner},
services::handle::ServiceHandle,
Services,
};
use utoipa::{
openapi::security::{ApiKey, ApiKeyValue, SecurityScheme},
@ -61,7 +61,6 @@ pub struct WebServer {
addr: SocketAddr,
}
#[async_trait::async_trait]
impl Backend for WebServer {
type Error = hyper::Error;

View File

@ -2,7 +2,6 @@ use crate::network::messages::*;
use crate::overlay::committees::*;
use crate::overlay::*;
use crate::*;
use async_trait::async_trait;
use bytes::Bytes;
use futures::Stream;
use nomos_core::fountain::FountainError;
@ -18,7 +17,6 @@ struct DummyOverlay;
struct DummyAdapter;
struct DummyBackend;
#[async_trait]
impl<N: NetworkAdapter + Sync, F: FountainCode + Sync> Overlay<N, F, MockTally> for DummyOverlay {
fn new(_: &View, _: NodeId) -> Self {
DummyOverlay
@ -52,7 +50,6 @@ impl<N: NetworkAdapter + Sync, F: FountainCode + Sync> Overlay<N, F, MockTally>
}
}
#[async_trait]
impl NetworkAdapter for DummyAdapter {
type Backend = DummyBackend;
async fn new(
@ -87,7 +84,6 @@ impl NetworkAdapter for DummyAdapter {
}
}
#[async_trait]
impl NetworkBackend for DummyBackend {
type Settings = ();
type State = NoState<()>;

View File

@ -7,8 +7,7 @@ use nomos_network::{
backends::mock::{Mock, MockBackendMessage, MockConfig, MockMessage},
NetworkConfig, NetworkMsg, NetworkService,
};
use overwatch_derive::*;
use overwatch_rs::{overwatch::OverwatchRunner, services::handle::ServiceHandle};
use overwatch_rs::{overwatch::OverwatchRunner, services::handle::ServiceHandle, Services};
use nomos_mempool::{
backend::mockpool::MockPool,

View File

@ -1,4 +1,5 @@
pub mod nodes;
use futures::Future;
use mixnet_node::MixnetNodeConfig;
use mixnet_topology::MixnetTopology;
pub use nodes::MixNode;
@ -38,11 +39,10 @@ pub fn adjust_timeout(d: Duration) -> Duration {
}
}
#[async_trait::async_trait]
pub trait Node: Sized {
type ConsensusInfo: Debug + Clone + PartialEq;
async fn spawn_nodes(config: SpawnConfig) -> Vec<Self>;
async fn consensus_info(&self) -> Self::ConsensusInfo;
fn spawn_nodes(config: SpawnConfig) -> impl Future<Output = Vec<Self>> + Send;
fn consensus_info(&self) -> impl Future<Output = Self::ConsensusInfo> + Send;
fn stop(&mut self);
}

View File

@ -197,7 +197,6 @@ impl NomosNode {
}
}
#[async_trait::async_trait]
impl Node for NomosNode {
type ConsensusInfo = CarnotInfo;
@ -341,8 +340,6 @@ fn create_node_config(
cors_origins: vec![],
},
},
#[cfg(feature = "metrics")]
metrics: Default::default(),
da: nomos_da::Settings {
da_protocol: full_replication::Settings {
voter: id,