Skip to content

Commit

Permalink
Pass timescale from CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
SupernaviX committed Oct 9, 2024
1 parent d9b2463 commit a6a6c53
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions sim-rs/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,11 @@ fn compute_latency(loc1: Location, loc2: Location, extra_ms: Option<u64>) -> Dur
geo_latency + extra_latency
}

pub fn read_config(filename: &Path) -> Result<SimConfiguration> {
pub fn read_config(filename: &Path, timescale: Option<u32>) -> Result<SimConfiguration> {
let file = fs::read_to_string(filename)?;
let raw_config: RawConfig = toml::from_str(&file)?;
let mut raw_config: RawConfig = toml::from_str(&file)?;
if let Some(ts) = timescale {
raw_config.timescale = Some(ts);
}
Ok(raw_config.into())
}
4 changes: 3 additions & 1 deletion sim-rs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ mod sim;
struct Args {
filename: PathBuf,
output: Option<PathBuf>,
#[clap(short, long)]
timescale: Option<u32>,
}

#[tokio::main]
Expand All @@ -42,7 +44,7 @@ async fn main() -> Result<()> {
})?;

let args = Args::parse();
let config = read_config(&args.filename)?;
let config = read_config(&args.filename, args.timescale)?;

let (events_sink, events_source) = mpsc::unbounded_channel();
let monitor = EventMonitor::new(&config, events_source, args.output).run();
Expand Down
1 change: 0 additions & 1 deletion sim-rs/test_data/simple.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
seed = 0x3c3373756e646165
timescale = 16
nodes = [
# producers
{ location = [-80, 40], stake = 1000000 },
Expand Down

0 comments on commit a6a6c53

Please sign in to comment.