mirror of
https://github.com/logos-co/nomos-simulations.git
synced 2025-01-11 11:14:51 +00:00
Empty mixnode in sim binary
This commit is contained in:
parent
c1b6649bd2
commit
7fb52dec17
@ -9,7 +9,8 @@ use clap::Parser;
|
|||||||
use nomos_simulations_network_runner::network::behaviour::create_behaviours;
|
use nomos_simulations_network_runner::network::behaviour::create_behaviours;
|
||||||
use nomos_simulations_network_runner::network::regions::{create_regions, RegionsData};
|
use nomos_simulations_network_runner::network::regions::{create_regions, RegionsData};
|
||||||
use nomos_simulations_network_runner::network::Network;
|
use nomos_simulations_network_runner::network::Network;
|
||||||
use nomos_simulations_network_runner::node::NodeId;
|
use nomos_simulations_network_runner::node::mix::{MixMessage, MixNode, MixNodeState};
|
||||||
|
use nomos_simulations_network_runner::node::{NodeId, NodeIdExt};
|
||||||
use nomos_simulations_network_runner::output_processors::{OutData, Record};
|
use nomos_simulations_network_runner::output_processors::{OutData, Record};
|
||||||
use nomos_simulations_network_runner::runner::{BoxedNode, SimulationRunnerHandle};
|
use nomos_simulations_network_runner::runner::{BoxedNode, SimulationRunnerHandle};
|
||||||
#[cfg(feature = "polars")]
|
#[cfg(feature = "polars")]
|
||||||
@ -67,7 +68,7 @@ impl SimulationApp {
|
|||||||
});
|
});
|
||||||
let mut rng = SmallRng::seed_from_u64(seed);
|
let mut rng = SmallRng::seed_from_u64(seed);
|
||||||
let mut node_ids: Vec<NodeId> = (0..simulation_settings.node_count)
|
let mut node_ids: Vec<NodeId> = (0..simulation_settings.node_count)
|
||||||
.map(|_| todo!())
|
.map(NodeId::from_index)
|
||||||
.collect();
|
.collect();
|
||||||
node_ids.shuffle(&mut rng);
|
node_ids.shuffle(&mut rng);
|
||||||
|
|
||||||
@ -76,7 +77,7 @@ impl SimulationApp {
|
|||||||
let regions_data = RegionsData::new(regions, behaviours);
|
let regions_data = RegionsData::new(regions, behaviours);
|
||||||
|
|
||||||
let ids = node_ids.clone();
|
let ids = node_ids.clone();
|
||||||
let network = Arc::new(Mutex::new(Network::<()>::new(regions_data, seed)));
|
let network = Arc::new(Mutex::new(Network::<MixMessage>::new(regions_data, seed)));
|
||||||
|
|
||||||
// if dump_overlay_info {
|
// if dump_overlay_info {
|
||||||
// dump_json_to_file(
|
// dump_json_to_file(
|
||||||
@ -89,19 +90,23 @@ impl SimulationApp {
|
|||||||
// )?;
|
// )?;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// let nodes: Vec<BoxedNode<_, _>> = node_ids
|
let nodes: Vec<BoxedNode<(), MixNodeState>> = node_ids
|
||||||
// .par_iter()
|
.par_iter()
|
||||||
// .copied()
|
.copied()
|
||||||
// .map(|node_id| todo!())
|
.map(|node_id| create_boxed_mixnode(node_id))
|
||||||
// .collect();
|
.collect();
|
||||||
// let network = Arc::try_unwrap(network)
|
let network = Arc::try_unwrap(network)
|
||||||
// .expect("network is not used anywhere else")
|
.expect("network is not used anywhere else")
|
||||||
// .into_inner();
|
.into_inner();
|
||||||
// run::<_, _, _>(network, nodes, simulation_settings, stream_type)?;
|
run::<_, _, _>(network, nodes, simulation_settings, stream_type)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn create_boxed_mixnode(node_id: NodeId) -> BoxedNode<(), MixNodeState> {
|
||||||
|
Box::new(MixNode::new(node_id, ()))
|
||||||
|
}
|
||||||
|
|
||||||
fn run<M: std::fmt::Debug, S, T>(
|
fn run<M: std::fmt::Debug, S, T>(
|
||||||
network: Network<M>,
|
network: Network<M>,
|
||||||
nodes: Vec<BoxedNode<S, T>>,
|
nodes: Vec<BoxedNode<S, T>>,
|
||||||
|
53
network-runner/src/node/mix/mod.rs
Normal file
53
network-runner/src/node/mix/mod.rs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use super::{Node, NodeId};
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Copy, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct MixNodeState {
|
||||||
|
pub mock_counter: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub enum MixMessage {
|
||||||
|
Dummy(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This node implementation only used for testing different streaming implementation purposes.
|
||||||
|
pub struct MixNode<S> {
|
||||||
|
id: NodeId,
|
||||||
|
state: MixNodeState,
|
||||||
|
#[allow(dead_code)]
|
||||||
|
settings: S,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<S: Send + Sync> MixNode<S> {
|
||||||
|
pub fn new(id: NodeId, settings: S) -> Self {
|
||||||
|
Self {
|
||||||
|
id,
|
||||||
|
state: MixNodeState::default(),
|
||||||
|
settings,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<S> Node for MixNode<S>
|
||||||
|
where
|
||||||
|
S: Send + Sync,
|
||||||
|
{
|
||||||
|
type Settings = S;
|
||||||
|
|
||||||
|
type State = MixNodeState;
|
||||||
|
|
||||||
|
fn id(&self) -> NodeId {
|
||||||
|
self.id
|
||||||
|
}
|
||||||
|
|
||||||
|
fn state(&self) -> &Self::State {
|
||||||
|
&self.state
|
||||||
|
}
|
||||||
|
|
||||||
|
fn step(&mut self, _: Duration) {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod dummy_streaming;
|
pub mod dummy_streaming;
|
||||||
|
pub mod mix;
|
||||||
|
|
||||||
// std
|
// std
|
||||||
use std::{
|
use std::{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user