Skip to content

Commit 19581f3

Browse files
committed
simln-lib/refactor: fully deterministic produce events
simln-lib/refactor: fully deterministic produce events
1 parent b23aa5f commit 19581f3

File tree

4 files changed

+204
-128
lines changed

4 files changed

+204
-128
lines changed

sim-cli/src/parsing.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use simln_lib::{
1414
Simulation, SimulationCfg, WriteResults,
1515
};
1616
use simln_lib::{ShortChannelID, SimulationError};
17-
use std::collections::HashMap;
17+
use std::collections::{BTreeMap, HashMap};
1818
use std::fs;
1919
use std::path::PathBuf;
2020
use std::sync::Arc;
@@ -262,7 +262,7 @@ pub async fn create_simulation_with_network(
262262
(
263263
Simulation<SimulationClock>,
264264
Vec<ActivityDefinition>,
265-
HashMap<PublicKey, Arc<Mutex<SimNode<SimGraph>>>>,
265+
BTreeMap<PublicKey, Arc<Mutex<SimNode<SimGraph>>>>,
266266
),
267267
anyhow::Error,
268268
> {
@@ -314,7 +314,7 @@ pub async fn create_simulation_with_network(
314314
// to a dyn trait and exclude any nodes that shouldn't be included in random activity
315315
// generation.
316316
let nodes = ln_node_from_graph(simulation_graph.clone(), routing_graph).await;
317-
let mut nodes_dyn: HashMap<_, Arc<Mutex<dyn LightningNode>>> = nodes
317+
let mut nodes_dyn: BTreeMap<_, Arc<Mutex<dyn LightningNode>>> = nodes
318318
.iter()
319319
.map(|(pk, node)| (*pk, Arc::clone(node) as Arc<Mutex<dyn LightningNode>>))
320320
.collect();
@@ -381,12 +381,12 @@ async fn get_clients(
381381
nodes: Vec<NodeConnection>,
382382
) -> Result<
383383
(
384-
HashMap<PublicKey, Arc<Mutex<dyn LightningNode>>>,
384+
BTreeMap<PublicKey, Arc<Mutex<dyn LightningNode>>>,
385385
HashMap<PublicKey, NodeInfo>,
386386
),
387387
LightningError,
388388
> {
389-
let mut clients: HashMap<PublicKey, Arc<Mutex<dyn LightningNode>>> = HashMap::new();
389+
let mut clients: BTreeMap<PublicKey, Arc<Mutex<dyn LightningNode>>> = BTreeMap::new();
390390
let mut clients_info: HashMap<PublicKey, NodeInfo> = HashMap::new();
391391

392392
for connection in nodes {
@@ -598,7 +598,7 @@ pub async fn parse_sim_params(cli: &Cli) -> anyhow::Result<SimParams> {
598598
}
599599

600600
pub async fn get_validated_activities(
601-
clients: &HashMap<PublicKey, Arc<Mutex<dyn LightningNode>>>,
601+
clients: &BTreeMap<PublicKey, Arc<Mutex<dyn LightningNode>>>,
602602
nodes_info: HashMap<PublicKey, NodeInfo>,
603603
activity: Vec<ActivityParser>,
604604
) -> Result<Vec<ActivityDefinition>, LightningError> {

0 commit comments

Comments
 (0)