@@ -5,7 +5,8 @@ use log::LevelFilter;
5
5
use serde:: { Deserialize , Serialize } ;
6
6
use simln_lib:: clock:: SimulationClock ;
7
7
use simln_lib:: sim_node:: {
8
- ln_node_from_graph, populate_network_graph, ChannelPolicy , SimGraph , SimulatedChannel ,
8
+ ln_node_from_graph, populate_network_graph, ChannelPolicy , Interceptor , SimGraph ,
9
+ SimulatedChannel ,
9
10
} ;
10
11
use simln_lib:: {
11
12
cln, cln:: ClnNode , eclair, eclair:: EclairNode , lnd, lnd:: LndNode , serializers,
@@ -87,6 +88,10 @@ pub struct Cli {
87
88
/// simulated nodes.
88
89
#[ clap( long) ]
89
90
pub speedup_clock : Option < u16 > ,
91
+ /// Latency to optionally introduce for payments in a simulated network expressed in
92
+ /// milliseconds.
93
+ #[ clap( long) ]
94
+ pub latency_ms : Option < u32 > ,
90
95
}
91
96
92
97
impl Cli {
@@ -112,6 +117,12 @@ impl Cli {
112
117
) ) ;
113
118
}
114
119
120
+ if !sim_params. nodes . is_empty ( ) && self . latency_ms . is_some ( ) {
121
+ return Err ( anyhow ! (
122
+ "Latency for payments is only allowed when running on a simulated network"
123
+ ) ) ;
124
+ }
125
+
115
126
Ok ( ( ) )
116
127
}
117
128
}
@@ -217,6 +228,7 @@ pub async fn create_simulation_with_network(
217
228
cli : & Cli ,
218
229
sim_params : & SimParams ,
219
230
tasks : TaskTracker ,
231
+ interceptors : Vec < Arc < dyn Interceptor > > ,
220
232
) -> Result < ( Simulation < SimulationClock > , Vec < ActivityDefinition > ) , anyhow:: Error > {
221
233
let cfg: SimulationCfg = SimulationCfg :: try_from ( cli) ?;
222
234
let SimParams {
@@ -246,7 +258,7 @@ pub async fn create_simulation_with_network(
246
258
SimGraph :: new (
247
259
channels. clone ( ) ,
248
260
tasks. clone ( ) ,
249
- vec ! [ ] ,
261
+ interceptors ,
250
262
( shutdown_trigger. clone ( ) , shutdown_listener. clone ( ) ) ,
251
263
)
252
264
. map_err ( |e| SimulationError :: SimulatedNetworkError ( format ! ( "{:?}" , e) ) ) ?,
0 commit comments