Skip to content

Commit 698b318

Browse files
authored
Merge pull request #292 from carlaKC/refactor-pass-clock-in
sim-cli/refactor: pass clock into create_simulation_with_network
2 parents 49d5ae4 + d22ab43 commit 698b318

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

sim-cli/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use clap::Parser;
44
use log::LevelFilter;
55
use sim_cli::parsing::{create_simulation, create_simulation_with_network, parse_sim_params, Cli};
66
use simln_lib::{
7+
clock::SimulationClock,
78
latency_interceptor::LatencyIntercepor,
89
sim_node::{CustomRecords, Interceptor},
910
SimulationCfg,
@@ -43,10 +44,11 @@ async fn main() -> anyhow::Result<()> {
4344
vec![]
4445
};
4546
let sim_cfg: SimulationCfg = SimulationCfg::try_from(&cli)?;
47+
let clock = Arc::new(SimulationClock::new(cli.speedup_clock.unwrap_or(1))?);
4648
let (sim, validated_activities, _) = create_simulation_with_network(
4749
sim_cfg,
4850
&sim_params,
49-
cli.speedup_clock.unwrap_or(1),
51+
clock,
5052
tasks.clone(),
5153
interceptors,
5254
CustomRecords::default(),

sim-cli/src/parsing.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ struct NodeMapping {
244244
pub async fn create_simulation_with_network(
245245
cfg: SimulationCfg,
246246
sim_params: &SimParams,
247-
clock_speedup: u16,
247+
clock: Arc<SimulationClock>,
248248
tasks: TaskTracker,
249249
interceptors: Vec<Arc<dyn Interceptor>>,
250250
custom_records: CustomRecords,
@@ -291,8 +291,6 @@ pub async fn create_simulation_with_network(
291291
.map_err(|e| SimulationError::SimulatedNetworkError(format!("{:?}", e)))?,
292292
));
293293

294-
let clock = Arc::new(SimulationClock::new(clock_speedup)?);
295-
296294
// Copy all simulated channels into a read-only routing graph, allowing to pathfind for
297295
// individual payments without locking th simulation graph (this is a duplication of the channels,
298296
// but the performance tradeoff is worthwhile for concurrent pathfinding).

0 commit comments

Comments
 (0)