@@ -95,29 +95,29 @@ pub struct SimParams {
95
95
/// [NodeId], which enables the use of public keys and aliases in the simulation description.
96
96
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
97
97
pub struct ActivityParser {
98
- // The source of the payment.
98
+ /// The source of the payment.
99
99
#[ serde( with = "serializers::serde_node_id" ) ]
100
100
pub source : NodeId ,
101
- // The destination of the payment.
101
+ /// The destination of the payment.
102
102
#[ serde( with = "serializers::serde_node_id" ) ]
103
103
pub destination : NodeId ,
104
- // The interval of the event, as in every how many seconds the payment is performed.
104
+ /// The interval of the event, as in every how many seconds the payment is performed.
105
105
pub interval_secs : u16 ,
106
- // The amount of m_sat to used in this payment.
106
+ /// The amount of m_sat to used in this payment.
107
107
pub amount_msat : u64 ,
108
108
}
109
109
110
110
/// Data structure used internally by the simulator. Both source and destination are represented as [PublicKey] here.
111
111
/// This is constructed during activity validation and passed along to the [Simulation].
112
112
#[ derive( Debug , Clone ) ]
113
113
pub struct ActivityDefinition {
114
- // The source of the payment.
114
+ /// The source of the payment.
115
115
pub source : NodeInfo ,
116
- // The destination of the payment.
116
+ /// The destination of the payment.
117
117
pub destination : NodeInfo ,
118
- // The interval of the event, as in every how many seconds the payment is performed.
118
+ /// The interval of the event, as in every how many seconds the payment is performed.
119
119
pub interval_secs : u16 ,
120
- // The amount of m_sat to used in this payment.
120
+ /// The amount of m_sat to used in this payment.
121
121
pub amount_msat : u64 ,
122
122
}
123
123
@@ -135,7 +135,6 @@ pub enum SimulationError {
135
135
RandomActivityError ( RandomActivityError ) ,
136
136
}
137
137
138
- // Phase 2: Event Queue
139
138
#[ derive( Debug , Error ) ]
140
139
pub enum LightningError {
141
140
#[ error( "Node connection error: {0}" ) ]
@@ -204,8 +203,8 @@ pub trait LightningNode: Send {
204
203
}
205
204
206
205
pub trait DestinationGenerator : Send {
207
- // choose_destination picks a destination node within the network, returning the node's information and its
208
- // capacity (if available).
206
+ /// choose_destination picks a destination node within the network, returning the node's information and its
207
+ /// capacity (if available).
209
208
fn choose_destination ( & self , source : PublicKey ) -> ( NodeInfo , Option < u64 > ) ;
210
209
}
211
210
@@ -214,10 +213,10 @@ pub trait DestinationGenerator: Send {
214
213
pub struct PaymentGenerationError ( String ) ;
215
214
216
215
pub trait PaymentGenerator : Display + Send {
217
- // Returns the number of seconds that a node should wait until firing its next payment.
216
+ /// Returns the number of seconds that a node should wait until firing its next payment.
218
217
fn next_payment_wait ( & self ) -> time:: Duration ;
219
218
220
- // Returns a payment amount based, with a destination capacity optionally provided to inform the amount picked.
219
+ /// Returns a payment amount based, with a destination capacity optionally provided to inform the amount picked.
221
220
fn payment_amount (
222
221
& self ,
223
222
destination_capacity : Option < u64 > ,
@@ -324,14 +323,14 @@ enum SimulationOutput {
324
323
325
324
#[ derive( Clone ) ]
326
325
pub struct Simulation {
327
- // The lightning node that is being simulated.
326
+ /// The lightning node that is being simulated.
328
327
nodes : HashMap < PublicKey , Arc < Mutex < dyn LightningNode > > > ,
329
- // The activity that are to be executed on the node.
328
+ /// The activity that are to be executed on the node.
330
329
activity : Vec < ActivityDefinition > ,
331
- // High level triggers used to manage simulation tasks and shutdown.
330
+ /// High level triggers used to manage simulation tasks and shutdown.
332
331
shutdown_trigger : Trigger ,
333
332
shutdown_listener : Listener ,
334
- // Total simulation time. The simulation will run forever if undefined.
333
+ /// Total simulation time. The simulation will run forever if undefined.
335
334
total_time : Option < time:: Duration > ,
336
335
/// The expected payment size for the network.
337
336
expected_payment_msat : u64 ,
@@ -425,7 +424,7 @@ impl Simulation {
425
424
Ok ( ( ) )
426
425
}
427
426
428
- // validates that the nodes are all on the same network and ensures that we're not running on mainnet.
427
+ /// validates that the nodes are all on the same network and ensures that we're not running on mainnet.
429
428
async fn validate_node_network ( & self ) -> Result < ( ) , LightningError > {
430
429
if self . nodes . is_empty ( ) {
431
430
return Err ( LightningError :: ValidationError (
@@ -531,8 +530,8 @@ impl Simulation {
531
530
self . shutdown_trigger . trigger ( )
532
531
}
533
532
534
- // run_data_collection starts the tasks required for the simulation to report of the results of the activity that
535
- // it generates. The simulation should report outputs via the receiver that is passed in.
533
+ /// run_data_collection starts the tasks required for the simulation to report of the results of the activity that
534
+ /// it generates. The simulation should report outputs via the receiver that is passed in.
536
535
fn run_data_collection (
537
536
& self ,
538
537
output_receiver : Receiver < SimulationOutput > ,
@@ -716,11 +715,11 @@ impl Simulation {
716
715
}
717
716
}
718
717
719
- // consume_events processes events that are crated for a lightning node that we can execute events on. Any output
720
- // that is generated from the event being executed is piped into a channel to handle the result of the event. If it
721
- // exits, it will use the trigger provided to trigger shutdown in other threads. If an error occurs elsewhere, we
722
- // expect the senders corresponding to our receiver to be dropped, which will cause the receiver to error out and
723
- // exit.
718
+ /// events that are crated for a lightning node that we can execute events on. Any output that is generated from the
719
+ /// event being executed is piped into a channel to handle the result of the event. If it exits, it will use the
720
+ /// trigger provided to trigger shutdown in other threads. If an error occurs elsewhere, we expect the senders
721
+ /// corresponding to our receiver to be dropped, which will cause the receiver to error out and
722
+ /// exit.
724
723
async fn consume_events (
725
724
node : Arc < Mutex < dyn LightningNode > > ,
726
725
mut receiver : Receiver < SimulationEvent > ,
@@ -787,8 +786,8 @@ async fn consume_events(
787
786
}
788
787
}
789
788
790
- // produce events generates events for the activity description provided. It accepts a shutdown listener so it can
791
- // exit if other threads signal that they have errored out.
789
+ /// produce events generates events for the activity description provided. It accepts a shutdown listener so it can
790
+ /// exit if other threads signal that they have errored out.
792
791
async fn produce_events < N : DestinationGenerator + ?Sized , A : PaymentGenerator + ?Sized > (
793
792
source : NodeInfo ,
794
793
network_generator : Arc < Mutex < N > > ,
0 commit comments