Skip to content

Commit

Permalink
multi: pass shutdown trigger into simulation
Browse files Browse the repository at this point in the history
To allow us to use a universal shutdown trigger, pass it into the
simulation.
  • Loading branch information
carlaKC committed Feb 9, 2024
1 parent 0f5fb6b commit 6f3c936
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sim-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ sim-lib = { path = "../sim-lib" }
tokio = { version = "1.26.0", features = ["full"] }
bitcoin = { version = "0.30.1" }
ctrlc = "3.4.0"
triggered = "0.1.2"
2 changes: 2 additions & 0 deletions sim-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,15 @@ async fn main() -> anyhow::Result<()> {
None
};

let (shutdown_trigger, shutdown_listener) = triggered::trigger();
let sim = Simulation::new(
clients,
validated_activities,
cli.total_time,
cli.expected_pmt_amt,
cli.capacity_multiplier,
write_results,
(shutdown_trigger, shutdown_listener),
);
let sim2 = sim.clone();

Expand Down
6 changes: 3 additions & 3 deletions sim-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,13 @@ impl Simulation {
expected_payment_msat: u64,
activity_multiplier: f64,
write_results: Option<WriteResults>,
shutdown: (Trigger, Listener),
) -> Self {
let (shutdown_trigger, shutdown_listener) = triggered::trigger();
Self {
nodes,
activity,
shutdown_trigger,
shutdown_listener,
shutdown_trigger: shutdown.0,
shutdown_listener: shutdown.1,
total_time: total_time.map(|x| Duration::from_secs(x as u64)),
expected_payment_msat,
activity_multiplier,
Expand Down

0 comments on commit 6f3c936

Please sign in to comment.