1- use bitcoin:: secp256k1:: PublicKey ;
21use anyhow:: anyhow;
2+ use bitcoin:: secp256k1:: PublicKey ;
33use clap:: { builder:: TypedValueParser , Parser } ;
4- use std :: path :: PathBuf ;
4+ use log :: LevelFilter ;
55use serde:: { Deserialize , Serialize } ;
66use simln_lib:: {
7- Amount , Interval , cln , lnd, serializers, NodeId , SimulationCfg , Simulation , WriteResults , LightningError , LightningNode ,
8- cln :: ClnNode , lnd :: LndNode , ActivityDefinition , NodeInfo
7+ cln , cln :: ClnNode , lnd , lnd:: LndNode , serializers, ActivityDefinition , Amount , Interval ,
8+ LightningError , LightningNode , NodeId , NodeInfo , Simulation , SimulationCfg , WriteResults ,
99} ;
10- use log:: LevelFilter ;
11- use std:: sync:: Arc ;
10+ use std:: collections:: HashMap ;
1211use std:: fs;
12+ use std:: path:: PathBuf ;
13+ use std:: sync:: Arc ;
1314use tokio:: sync:: Mutex ;
14- use std:: collections:: HashMap ;
1515
1616/// The default directory where the simulation files are stored and where the results will be written to.
1717pub const DEFAULT_DATA_DIR : & str = "." ;
@@ -138,10 +138,7 @@ impl TryFrom<&Cli> for SimulationCfg {
138138
139139/// Parses the cli options provided and creates a simulation to be run, connecting to lightning nodes and validating
140140/// any activity described in the simulation file.
141- pub async fn create_simulation (
142- cli : & Cli ,
143- ) -> Result < Simulation , anyhow:: Error > {
144-
141+ pub async fn create_simulation ( cli : & Cli ) -> Result < Simulation , anyhow:: Error > {
145142 let cfg: SimulationCfg = SimulationCfg :: try_from ( cli) ?;
146143
147144 let sim_path = read_sim_path ( cli. data_dir . clone ( ) , cli. sim_file . clone ( ) ) . await ?;
@@ -168,12 +165,8 @@ pub async fn create_simulation(
168165 ) )
169166 } ;
170167
171- let validated_activities = validate_activities (
172- activity,
173- & clients_info,
174- get_node
175- ) . await ?;
176-
168+ let validated_activities = validate_activities ( activity, & clients_info, get_node) . await ?;
169+
177170 Ok ( Simulation :: new ( cfg, clients, validated_activities) )
178171}
179172
@@ -212,7 +205,7 @@ async fn get_clients(
212205/// Adds a lightning node to a client map and tracking maps used to lookup node pubkeys and aliases for activity
213206/// validation.
214207async fn add_node_to_maps (
215- nodes : & HashMap < PublicKey , NodeInfo >
208+ nodes : & HashMap < PublicKey , NodeInfo > ,
216209) -> Result < ( HashMap < PublicKey , NodeInfo > , HashMap < String , NodeInfo > ) , LightningError > {
217210 let mut pk_node_map = HashMap :: new ( ) ;
218211 let mut alias_node_map = HashMap :: new ( ) ;
@@ -255,10 +248,6 @@ async fn validate_activities(
255248 nodes : & HashMap < PublicKey , NodeInfo > ,
256249 get_node_info : impl AsyncFn ( & PublicKey ) -> Result < NodeInfo , LightningError > ,
257250) -> Result < Vec < ActivityDefinition > , LightningError > {
258- if activity. is_empty ( ) {
259- return Ok ( vec ! [ ] ) ;
260- }
261-
262251 let mut validated_activities = vec ! [ ] ;
263252 let ( pk_node_map, alias_node_map) = add_node_to_maps ( nodes) . await ?;
264253
0 commit comments