Skip to content

Commit a6a6c53

Browse files
committed
Pass timescale from CLI
1 parent d9b2463 commit a6a6c53

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

sim-rs/src/config.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,11 @@ fn compute_latency(loc1: Location, loc2: Location, extra_ms: Option<u64>) -> Dur
146146
geo_latency + extra_latency
147147
}
148148

149-
pub fn read_config(filename: &Path) -> Result<SimConfiguration> {
149+
pub fn read_config(filename: &Path, timescale: Option<u32>) -> Result<SimConfiguration> {
150150
let file = fs::read_to_string(filename)?;
151-
let raw_config: RawConfig = toml::from_str(&file)?;
151+
let mut raw_config: RawConfig = toml::from_str(&file)?;
152+
if let Some(ts) = timescale {
153+
raw_config.timescale = Some(ts);
154+
}
152155
Ok(raw_config.into())
153156
}

sim-rs/src/main.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ mod sim;
2323
struct Args {
2424
filename: PathBuf,
2525
output: Option<PathBuf>,
26+
#[clap(short, long)]
27+
timescale: Option<u32>,
2628
}
2729

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

4446
let args = Args::parse();
45-
let config = read_config(&args.filename)?;
47+
let config = read_config(&args.filename, args.timescale)?;
4648

4749
let (events_sink, events_source) = mpsc::unbounded_channel();
4850
let monitor = EventMonitor::new(&config, events_source, args.output).run();

sim-rs/test_data/simple.toml

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
seed = 0x3c3373756e646165
2-
timescale = 16
32
nodes = [
43
# producers
54
{ location = [-80, 40], stake = 1000000 },

0 commit comments

Comments
 (0)