Skip to content

Commit 7b34635

Browse files
committed
simln-lib: move results to Simulation rather than SimulationCfg
Accidentally reverted in a rebase.
1 parent 90e861b commit 7b34635

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

simln-lib/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,6 @@ pub struct SimulationCfg {
488488
write_results: Option<WriteResults>,
489489
/// Random number generator created from fixed seed.
490490
seeded_rng: MutRng,
491-
/// Results logger that holds the simulation statistics.
492-
results: Arc<Mutex<PaymentResultLogger>>,
493491
}
494492

495493
impl SimulationCfg {
@@ -506,7 +504,6 @@ impl SimulationCfg {
506504
activity_multiplier,
507505
write_results,
508506
seeded_rng: MutRng::new(seed),
509-
results: Arc::new(Mutex::new(PaymentResultLogger::new())),
510507
}
511508
}
512509
}
@@ -519,6 +516,8 @@ pub struct Simulation {
519516
nodes: HashMap<PublicKey, Arc<Mutex<dyn LightningNode>>>,
520517
/// The activity that are to be executed on the node.
521518
activity: Vec<ActivityDefinition>,
519+
/// Results logger that holds the simulation statistics.
520+
results: Arc<Mutex<PaymentResultLogger>>,
522521
/// High level triggers used to manage simulation tasks and shutdown.
523522
shutdown_trigger: Trigger,
524523
shutdown_listener: Listener,
@@ -553,6 +552,7 @@ impl Simulation {
553552
cfg,
554553
nodes,
555554
activity,
555+
results: Arc::new(Mutex::new(PaymentResultLogger::new())),
556556
shutdown_trigger,
557557
shutdown_listener,
558558
}
@@ -760,11 +760,11 @@ impl Simulation {
760760
}
761761

762762
pub async fn get_total_payments(&self) -> u64 {
763-
self.cfg.results.lock().await.total_attempts()
763+
self.results.lock().await.total_attempts()
764764
}
765765

766766
pub async fn get_success_rate(&self) -> f64 {
767-
self.cfg.results.lock().await.success_rate()
767+
self.results.lock().await.success_rate()
768768
}
769769

770770
/// 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 {
798798
}
799799
});
800800

801-
let result_logger = self.cfg.results.clone();
801+
let result_logger = self.results.clone();
802802

803803
let result_logger_clone = result_logger.clone();
804804
let result_logger_listener = listener.clone();

0 commit comments

Comments
 (0)