Skip to content

Commit 4b1d797

Browse files
committed
simln-lib/refactor: add and change comments on events queue flow
1 parent 647d43e commit 4b1d797

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

simln-lib/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,8 @@ impl<C: Clock + 'static> Simulation<C> {
820820
},
821821
};
822822

823-
// Next, it is necessary to generate all defined activities in a central place.
823+
// Setup a task that will populate a single events queue with payments to dispatch, and
824+
// report their outcome to our data collection.
824825
match self
825826
.setup_payment_events(activities, event_sender, &self.tasks)
826827
.await
@@ -1046,7 +1047,8 @@ impl<C: Clock + 'static> Simulation<C> {
10461047
Ok(generators)
10471048
}
10481049

1049-
/// It is the central place responsible for create payment events.
1050+
/// Populates a queue of payment events with one event per executing node, then spawns a task
1051+
/// that will be responsible for reading, dispatching and replenishing them.
10501052
async fn setup_payment_events(
10511053
&self,
10521054
mut executors: Vec<ExecutorKit>,
@@ -1069,7 +1071,6 @@ impl<C: Clock + 'static> Simulation<C> {
10691071
generate_payment(&mut heap, source, &mut payments_tracker, now).await?;
10701072
}
10711073

1072-
// ppe: produce payment events
10731074
let shutdown = self.shutdown_trigger.clone();
10741075
let listener = self.shutdown_listener.clone();
10751076
let clock = self.clock.clone();
@@ -1102,6 +1103,8 @@ impl<C: Clock + 'static> Simulation<C> {
11021103
}
11031104
}
11041105

1106+
/// Reads and dispatches events from the heap provided, pushing more events to the queue where
1107+
/// appropriate for the defined activity.
11051108
async fn produce_payment_events<C: Clock>(
11061109
mut heap: BinaryHeap<Reverse<PaymentEvent>>,
11071110
mut payments_tracker: HashMap<PublicKey, ExecutorPaymentTracker>,

0 commit comments

Comments
 (0)