Skip to content

Commit 5936a15

Browse files
committed
Cleaning up comments, variable names, and imports
1 parent e031ddd commit 5936a15

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

simln-lib/src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::{collections::HashMap, sync::Arc, time::SystemTime};
1919
use thiserror::Error;
2020
use tokio::sync::mpsc::{channel, Receiver, Sender};
2121
use tokio::sync::Mutex;
22-
use tokio::{select, time, time::Duration, time::Instant};
22+
use tokio::{select, time, time::Duration, time::Instant, time::Sleep};
2323
use tokio_util::task::TaskTracker;
2424
use triggered::{Listener, Trigger};
2525

@@ -1272,8 +1272,7 @@ async fn run_results_logger(
12721272
///
12731273
/// Note: this producer does not accept a shutdown trigger because it only expects to be dispatched once. In the single
12741274
/// producer case exit will drop the only sending channel and the receiving channel provided to the consumer will error
1275-
/// out. In the multiple-producer case, a single producer shutting down does not drop *all* sending channels so the
1276-
/// consumer will not exit and a trigger is required.
1275+
/// out.
12771276
async fn produce_simulation_results(
12781277
nodes: HashMap<PublicKey, Arc<Mutex<dyn LightningNode>>>,
12791278
mut output_receiver: Receiver<SimulationOutput>,
@@ -1336,27 +1335,28 @@ async fn track_payment_result(
13361335
log::debug!("Tracking payment outcome for: {}.", hex::encode(hash.0));
13371336

13381337
// Trigger and listener to stop the implementation specific track payment functions (node.track_payment())
1339-
let (stop, listen) = triggered::trigger();
1338+
let (track_payment_trigger, track_payment_listener) = triggered::trigger();
13401339

13411340
// Timer for waiting after getting the shutdown signal in order for current tracking to complete
1342-
let mut timer: Option<tokio::time::Sleep> = None;
1341+
let mut timer: Option<Sleep> = None;
1342+
let mut timer_started = false;
13431343

13441344
loop {
13451345
tokio::select! {
1346-
biased;
13471346
// The shutdown listener is triggered and we have not started a timer yet
1348-
_ = async {}, if listener.clone().is_triggered() && timer.is_none() => {
1347+
_ = async {}, if listener.clone().is_triggered() && !timer_started => {
13491348
log::debug!("Shutdown received by track_payment_result, starting timer...");
13501349
timer = Some(time::sleep_until(Instant::now() + Duration::from_secs(3)));
1350+
timer_started = true;
13511351
},
13521352
// The timer has been started and it expires
13531353
Some(_) = conditional_sleeper(timer) => {
13541354
log::error!("Track payment failed for {}. The shutdown timer expired.", hex::encode(hash.0));
1355-
stop.trigger();
1355+
track_payment_trigger.trigger();
13561356
timer = None;
13571357
}
13581358
// The payment tracking completes
1359-
res = node.track_payment(&hash, listen.clone()) => {
1359+
res = node.track_payment(&hash, track_payment_listener.clone()) => {
13601360
match res {
13611361
Ok(res) => {
13621362
log::info!(
@@ -1396,7 +1396,7 @@ async fn track_payment_result(
13961396
Ok(())
13971397
}
13981398

1399-
async fn conditional_sleeper(t: Option<tokio::time::Sleep>) -> Option<()> {
1399+
async fn conditional_sleeper(t: Option<Sleep>) -> Option<()> {
14001400
match t {
14011401
Some(timer) => {
14021402
timer.await;

0 commit comments

Comments
 (0)