diff --git a/lib/simulon/examples/simple.rs b/lib/simulon/examples/simple.rs deleted file mode 100644 index 49e41c12b..000000000 --- a/lib/simulon/examples/simple.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![allow(dead_code)] - -use simulon::scene::ServerId; - -fn node(_id: ServerId, ctx: &simulon::context::Context) { - ctx.spawn(async { - while let Some(conn) = ctx.accept(69).await { - handle_connection(conn); - } - }); - - todo!() -} - -fn handle_connection(_conn: simulon::connection::Connection) { - todo!() -} - -fn main() { - // init scene. - // run node. -} diff --git a/lib/simulon/src/context.rs b/lib/simulon/src/context.rs index 100dc194d..154c5b0a1 100644 --- a/lib/simulon/src/context.rs +++ b/lib/simulon/src/context.rs @@ -1,15 +1,15 @@ use std::{future::Future, time::Duration}; -use crate::{connection::Connection, scene::ServerId}; +use crate::{connection::Connection, peer::PeerId}; pub struct Context {} impl Context { - pub fn peer_list(&self) -> &Vec { + pub fn peer_list(&self) -> &Vec { todo!() } - pub async fn dial(&self, _peer: &ServerId, _port: u8) -> Option { + pub async fn dial(&self, _peer: &PeerId, _port: u8) -> Option { todo!() } @@ -21,6 +21,10 @@ impl Context { todo!() } + pub async fn yield_execution() { + todo!() + } + pub fn spawn(&self, _future: impl Future) { todo!() } diff --git a/lib/simulon/src/lib.rs b/lib/simulon/src/lib.rs index 6a6152498..7fb926291 100644 --- a/lib/simulon/src/lib.rs +++ b/lib/simulon/src/lib.rs @@ -9,4 +9,3 @@ pub mod engine; pub mod futures; pub mod peer; pub mod ping; -pub mod scene; diff --git a/lib/simulon/src/scene.rs b/lib/simulon/src/scene.rs deleted file mode 100644 index 1da3f1429..000000000 --- a/lib/simulon/src/scene.rs +++ /dev/null @@ -1,70 +0,0 @@ -use std::time::Duration; - -use crate::{bandwidth::Bandwidth, ping::PingStat}; - -/// How many frames equal 1ms? -pub const MS_IN_FRAMES: u64 = 4; - -/// Set each frame to 250μs or forth of a millisecond. -pub const FRAME_DURATION: Duration = Duration::from_micros(250); - -/// Default value used as the window size for TCP emulation. -pub const DEFAULT_TCP_WINDOW_SIZE: usize = 64 << 10; - -/// Identifier for a single server. -#[derive(Hash, PartialEq, PartialOrd, Ord, Eq, Clone, Copy, Debug)] -pub struct ServerId(usize); - -/// The scene is where a simulation takes place. -pub struct Scene { - /// The current time. - pub time: Duration, -} - -/// An on-going transmission. -pub struct Transmission { - /// The data being sent. - pub data: Vec, - /// The number of bits received so far. - pub recivied: usize, - /// The window size of this transmission. - pub window_size: usize, -} - -/// The data provider returns the estimated statistics between different -/// servers and their peer to peer interaction with each other. -pub trait SceneDataProvider { - /// Returns the ping data between the given source and destination. - fn ping(&self, source: ServerId, destination: ServerId) -> PingStat; - - /// Returns the bandwidth associated with the given server. - fn bandwidth(&self, source: ServerId) -> Bandwidth; -} - -impl Scene { - /// Create and return a new scene. - pub fn new() -> Self { - Self { - time: Duration::ZERO, - } - } - - /// Run the simulation for the given time. This is not the time it will take - /// for this function to finish execution but it is rather the amount of time - /// that will be simulated in this run. The simulation kicks of from where it - /// was left off. - pub fn run(&mut self, _duration: Duration) { - todo!() - } - - /// Render a single frame of the simulation. - fn _render_frame(&mut self) { - todo!() - } -} - -impl Default for Scene { - fn default() -> Self { - Self::new() - } -}