Skip to content

Commit f68d2cd

Browse files
committed
sim-cli: pass cfg instead of cli to network creation
1 parent 0f75d43 commit f68d2cd

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

sim-cli/src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use sim_cli::parsing::{create_simulation, create_simulation_with_network, parse_
66
use simln_lib::{
77
latency_interceptor::LatencyIntercepor,
88
sim_node::{CustomRecords, Interceptor},
9+
SimulationCfg,
910
};
1011
use simple_logger::SimpleLogger;
1112
use tokio_util::task::TaskTracker;
@@ -41,9 +42,11 @@ async fn main() -> anyhow::Result<()> {
4142
} else {
4243
vec![]
4344
};
45+
let sim_cfg: SimulationCfg = SimulationCfg::try_from(&cli)?;
4446
create_simulation_with_network(
45-
&cli,
47+
sim_cfg,
4648
&sim_params,
49+
cli.speedup_clock.unwrap_or(1),
4750
tasks.clone(),
4851
interceptors,
4952
CustomRecords::default(),

sim-cli/src/parsing.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl Cli {
145145
#[derive(Debug, Serialize, Deserialize, Clone)]
146146
pub struct SimParams {
147147
#[serde(default)]
148-
nodes: Vec<NodeConnection>,
148+
pub nodes: Vec<NodeConnection>,
149149
#[serde(default)]
150150
pub sim_network: Vec<NetworkParser>,
151151
#[serde(default)]
@@ -242,13 +242,13 @@ struct NodeMapping {
242242
}
243243

244244
pub async fn create_simulation_with_network(
245-
cli: &Cli,
245+
cfg: SimulationCfg,
246246
sim_params: &SimParams,
247+
clock_speedup: u16,
247248
tasks: TaskTracker,
248249
interceptors: Vec<Arc<dyn Interceptor>>,
249250
custom_records: CustomRecords,
250251
) -> Result<(Simulation<SimulationClock>, Vec<ActivityDefinition>), anyhow::Error> {
251-
let cfg: SimulationCfg = SimulationCfg::try_from(cli)?;
252252
let SimParams {
253253
nodes: _,
254254
sim_network,
@@ -284,7 +284,7 @@ pub async fn create_simulation_with_network(
284284
.map_err(|e| SimulationError::SimulatedNetworkError(format!("{:?}", e)))?,
285285
));
286286

287-
let clock = Arc::new(SimulationClock::new(cli.speedup_clock.unwrap_or(1))?);
287+
let clock = Arc::new(SimulationClock::new(clock_speedup)?);
288288

289289
// Copy all simulated channels into a read-only routing graph, allowing to pathfind for
290290
// individual payments without locking th simulation graph (this is a duplication of the channels,

0 commit comments

Comments
 (0)