From 7b3463577a457d9b78c78309192953a5fbc36fac Mon Sep 17 00:00:00 2001 From: Carla Kirk-Cohen Date: Wed, 20 Nov 2024 14:37:35 -0500 Subject: [PATCH] simln-lib: move results to Simulation rather than SimulationCfg Accidentally reverted in a rebase. --- simln-lib/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/simln-lib/src/lib.rs b/simln-lib/src/lib.rs index 3cccf8c2..11db01e7 100644 --- a/simln-lib/src/lib.rs +++ b/simln-lib/src/lib.rs @@ -488,8 +488,6 @@ pub struct SimulationCfg { write_results: Option, /// Random number generator created from fixed seed. seeded_rng: MutRng, - /// Results logger that holds the simulation statistics. - results: Arc>, } impl SimulationCfg { @@ -506,7 +504,6 @@ impl SimulationCfg { activity_multiplier, write_results, seeded_rng: MutRng::new(seed), - results: Arc::new(Mutex::new(PaymentResultLogger::new())), } } } @@ -519,6 +516,8 @@ pub struct Simulation { nodes: HashMap>>, /// The activity that are to be executed on the node. activity: Vec, + /// Results logger that holds the simulation statistics. + results: Arc>, /// High level triggers used to manage simulation tasks and shutdown. shutdown_trigger: Trigger, shutdown_listener: Listener, @@ -553,6 +552,7 @@ impl Simulation { cfg, nodes, activity, + results: Arc::new(Mutex::new(PaymentResultLogger::new())), shutdown_trigger, shutdown_listener, } @@ -760,11 +760,11 @@ impl Simulation { } pub async fn get_total_payments(&self) -> u64 { - self.cfg.results.lock().await.total_attempts() + self.results.lock().await.total_attempts() } pub async fn get_success_rate(&self) -> f64 { - self.cfg.results.lock().await.success_rate() + self.results.lock().await.success_rate() } /// run_data_collection starts the tasks required for the simulation to report of the results of the activity that @@ -798,7 +798,7 @@ impl Simulation { } }); - let result_logger = self.cfg.results.clone(); + let result_logger = self.results.clone(); let result_logger_clone = result_logger.clone(); let result_logger_listener = listener.clone();