Skip to content

Commit

Permalink
simln-lib: move results to Simulation rather than SimulationCfg
Browse files Browse the repository at this point in the history
Accidentally reverted in a rebase.
  • Loading branch information
carlaKC committed Nov 20, 2024
1 parent 90e861b commit 7b34635
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions simln-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,6 @@ pub struct SimulationCfg {
write_results: Option<WriteResults>,
/// Random number generator created from fixed seed.
seeded_rng: MutRng,
/// Results logger that holds the simulation statistics.
results: Arc<Mutex<PaymentResultLogger>>,
}

impl SimulationCfg {
Expand All @@ -506,7 +504,6 @@ impl SimulationCfg {
activity_multiplier,
write_results,
seeded_rng: MutRng::new(seed),
results: Arc::new(Mutex::new(PaymentResultLogger::new())),
}
}
}
Expand All @@ -519,6 +516,8 @@ pub struct Simulation {
nodes: HashMap<PublicKey, Arc<Mutex<dyn LightningNode>>>,
/// The activity that are to be executed on the node.
activity: Vec<ActivityDefinition>,
/// Results logger that holds the simulation statistics.
results: Arc<Mutex<PaymentResultLogger>>,
/// High level triggers used to manage simulation tasks and shutdown.
shutdown_trigger: Trigger,
shutdown_listener: Listener,
Expand Down Expand Up @@ -553,6 +552,7 @@ impl Simulation {
cfg,
nodes,
activity,
results: Arc::new(Mutex::new(PaymentResultLogger::new())),
shutdown_trigger,
shutdown_listener,
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7b34635

Please sign in to comment.