Separate nomos node into bin and lib sections (#209)
This commit is contained in:
parent
18bbf63a3f
commit
8fad13b0cc
@ -1,14 +1,13 @@
|
||||
// std
|
||||
// crates
|
||||
use crate::Carnot;
|
||||
use bytes::Bytes;
|
||||
use http::StatusCode;
|
||||
use nomos_consensus::{CarnotInfo, ConsensusMsg};
|
||||
|
||||
use tokio::sync::mpsc::Sender;
|
||||
use tokio::sync::oneshot;
|
||||
use tracing::error;
|
||||
// internal
|
||||
use crate::tx::Tx;
|
||||
use futures::future::join_all;
|
||||
use multiaddr::Multiaddr;
|
||||
use nomos_core::wire;
|
||||
@ -22,6 +21,7 @@ use nomos_mempool::network::adapters::waku::{
|
||||
use nomos_mempool::{MempoolMetrics, MempoolMsg, MempoolService};
|
||||
use nomos_network::backends::waku::{Waku, WakuBackendMessage, WakuInfo};
|
||||
use nomos_network::{NetworkMsg, NetworkService};
|
||||
use nomos_node::{Carnot, Tx};
|
||||
use overwatch_rs::services::relay::OutboundRelay;
|
||||
use waku_bindings::WakuMessage;
|
||||
|
||||
|
54
nodes/nomos-node/src/lib.rs
Normal file
54
nodes/nomos-node/src/lib.rs
Normal file
@ -0,0 +1,54 @@
|
||||
mod tx;
|
||||
|
||||
use color_eyre::eyre::Result;
|
||||
use consensus_engine::overlay::{FlatOverlay, RoundRobin};
|
||||
#[cfg(feature = "metrics")]
|
||||
use metrics::{backend::map::MapMetricsBackend, types::MetricsData, MetricsService};
|
||||
use nomos_consensus::{
|
||||
network::adapters::waku::WakuAdapter as ConsensusWakuAdapter, CarnotConsensus,
|
||||
};
|
||||
use nomos_core::fountain::mock::MockFountain;
|
||||
use nomos_http::backends::axum::AxumBackend;
|
||||
use nomos_http::bridge::HttpBridgeService;
|
||||
use nomos_http::http::HttpService;
|
||||
use nomos_log::Logger;
|
||||
use nomos_mempool::{
|
||||
backend::mockpool::MockPool, network::adapters::waku::WakuAdapter as MempoolWakuAdapter,
|
||||
MempoolService,
|
||||
};
|
||||
use nomos_network::{backends::waku::Waku, NetworkService};
|
||||
use overwatch_derive::*;
|
||||
use overwatch_rs::services::{handle::ServiceHandle, ServiceData};
|
||||
use serde::Deserialize;
|
||||
|
||||
pub use tx::Tx;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct Config {
|
||||
pub log: <Logger as ServiceData>::Settings,
|
||||
pub network: <NetworkService<Waku> as ServiceData>::Settings,
|
||||
pub http: <HttpService<AxumBackend> as ServiceData>::Settings,
|
||||
pub consensus: <Carnot as ServiceData>::Settings,
|
||||
#[cfg(feature = "metrics")]
|
||||
pub metrics: <MetricsService<MapMetricsBackend<MetricsData>> as ServiceData>::Settings,
|
||||
}
|
||||
|
||||
pub type Carnot = CarnotConsensus<
|
||||
ConsensusWakuAdapter,
|
||||
MockPool<Tx>,
|
||||
MempoolWakuAdapter<Tx>,
|
||||
MockFountain,
|
||||
FlatOverlay<RoundRobin>,
|
||||
>;
|
||||
|
||||
#[derive(Services)]
|
||||
pub struct Nomos {
|
||||
logging: ServiceHandle<Logger>,
|
||||
network: ServiceHandle<NetworkService<Waku>>,
|
||||
mockpool: ServiceHandle<MempoolService<MempoolWakuAdapter<Tx>, MockPool<Tx>>>,
|
||||
consensus: ServiceHandle<Carnot>,
|
||||
http: ServiceHandle<HttpService<AxumBackend>>,
|
||||
bridges: ServiceHandle<HttpBridgeService>,
|
||||
#[cfg(feature = "metrics")]
|
||||
metrics: ServiceHandle<MetricsService<MapMetricsBackend<MetricsData>>>,
|
||||
}
|
@ -1,34 +1,14 @@
|
||||
use nomos_node::{Config, Nomos, NomosServiceSettings};
|
||||
|
||||
mod bridges;
|
||||
mod tx;
|
||||
|
||||
use clap::Parser;
|
||||
use color_eyre::eyre::{eyre, Result};
|
||||
use consensus_engine::overlay::{FlatOverlay, RoundRobin};
|
||||
#[cfg(feature = "metrics")]
|
||||
use metrics::{backend::map::MapMetricsBackend, types::MetricsData, MetricsService};
|
||||
use nomos_consensus::{
|
||||
network::adapters::waku::WakuAdapter as ConsensusWakuAdapter, CarnotConsensus,
|
||||
};
|
||||
use nomos_core::fountain::mock::MockFountain;
|
||||
use nomos_http::backends::axum::AxumBackend;
|
||||
use nomos_http::bridge::{HttpBridge, HttpBridgeService, HttpBridgeSettings};
|
||||
use nomos_http::http::HttpService;
|
||||
use nomos_log::Logger;
|
||||
use nomos_mempool::{
|
||||
backend::mockpool::MockPool, network::adapters::waku::WakuAdapter as MempoolWakuAdapter,
|
||||
MempoolService,
|
||||
};
|
||||
use nomos_network::{backends::waku::Waku, NetworkService};
|
||||
use overwatch_derive::*;
|
||||
use overwatch_rs::{
|
||||
overwatch::*,
|
||||
services::{handle::ServiceHandle, ServiceData},
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use std::sync::Arc;
|
||||
use tx::Tx;
|
||||
use nomos_http::bridge::{HttpBridge, HttpBridgeSettings};
|
||||
|
||||
use overwatch_rs::overwatch::*;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Simple program to greet a person
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
struct Args {
|
||||
@ -36,36 +16,6 @@ struct Args {
|
||||
config: std::path::PathBuf,
|
||||
}
|
||||
|
||||
type Carnot = CarnotConsensus<
|
||||
ConsensusWakuAdapter,
|
||||
MockPool<Tx>,
|
||||
MempoolWakuAdapter<Tx>,
|
||||
MockFountain,
|
||||
FlatOverlay<RoundRobin>,
|
||||
>;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Config {
|
||||
log: <Logger as ServiceData>::Settings,
|
||||
network: <NetworkService<Waku> as ServiceData>::Settings,
|
||||
http: <HttpService<AxumBackend> as ServiceData>::Settings,
|
||||
consensus: <Carnot as ServiceData>::Settings,
|
||||
#[cfg(feature = "metrics")]
|
||||
metrics: <MetricsService<MapMetricsBackend<MetricsData>> as ServiceData>::Settings,
|
||||
}
|
||||
|
||||
#[derive(Services)]
|
||||
struct Nomos {
|
||||
logging: ServiceHandle<Logger>,
|
||||
network: ServiceHandle<NetworkService<Waku>>,
|
||||
mockpool: ServiceHandle<MempoolService<MempoolWakuAdapter<Tx>, MockPool<Tx>>>,
|
||||
consensus: ServiceHandle<Carnot>,
|
||||
http: ServiceHandle<HttpService<AxumBackend>>,
|
||||
bridges: ServiceHandle<HttpBridgeService>,
|
||||
#[cfg(feature = "metrics")]
|
||||
metrics: ServiceHandle<MetricsService<MapMetricsBackend<MetricsData>>>,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let Args { config } = Args::parse();
|
||||
let config = serde_yaml::from_reader::<_, Config>(std::fs::File::open(config)?)?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user