diff --git a/Cargo.lock b/Cargo.lock index 95199b79..639f722c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1697,6 +1697,7 @@ dependencies = [ "sim-lib", "simple_logger", "tokio", + "triggered", ] [[package]] diff --git a/sim-cli/Cargo.toml b/sim-cli/Cargo.toml index 67a6f41b..0dce023b 100644 --- a/sim-cli/Cargo.toml +++ b/sim-cli/Cargo.toml @@ -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" diff --git a/sim-cli/src/main.rs b/sim-cli/src/main.rs index 545a5104..a4c06771 100644 --- a/sim-cli/src/main.rs +++ b/sim-cli/src/main.rs @@ -199,6 +199,7 @@ async fn main() -> anyhow::Result<()> { None }; + let (shutdown_trigger, shutdown_listener) = triggered::trigger(); let sim = Simulation::new( clients, validated_activities, @@ -206,6 +207,7 @@ async fn main() -> anyhow::Result<()> { cli.expected_pmt_amt, cli.capacity_multiplier, write_results, + (shutdown_trigger, shutdown_listener), ); let sim2 = sim.clone(); diff --git a/sim-lib/src/lib.rs b/sim-lib/src/lib.rs index a64e8ba8..336a8dcb 100644 --- a/sim-lib/src/lib.rs +++ b/sim-lib/src/lib.rs @@ -368,13 +368,13 @@ impl Simulation { expected_payment_msat: u64, activity_multiplier: f64, write_results: Option, + 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,