Skip to content

Commit 123d283

Browse files
committed
fixup! sim-ln/feat: Track Clock in SimNode
1 parent b64d0f7 commit 123d283

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

sim-cli/src/parsing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ pub async fn create_simulation_with_network(
313313
// custom actions on the simulated network. For the nodes we'll pass our simulation, cast them
314314
// to a dyn trait and exclude any nodes that shouldn't be included in random activity
315315
// generation.
316-
let nodes = ln_node_from_graph(simulation_graph.clone(), routing_graph).await?;
316+
let nodes = ln_node_from_graph(simulation_graph.clone(), routing_graph, SystemClock {}).await?;
317317
let mut nodes_dyn: HashMap<_, Arc<Mutex<dyn LightningNode>>> = nodes
318318
.iter()
319319
.map(|(pk, node)| (*pk, Arc::clone(node) as Arc<Mutex<dyn LightningNode>>))

simln-lib/src/clock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub trait Clock: Send + Sync {
1212
}
1313

1414
/// Provides a wall clock implementation of the Clock trait.
15-
#[derive(Clone)]
15+
#[derive(Clone, Copy)]
1616
pub struct SystemClock {}
1717

1818
#[async_trait]

simln-lib/src/sim_node.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::clock::{Clock, SystemClock};
1+
use crate::clock::Clock;
22
use crate::{
33
Graph, LightningError, LightningNode, NodeInfo, PaymentOutcome, PaymentResult, SimulationError,
44
};
@@ -1061,11 +1061,12 @@ impl SimGraph {
10611061
}
10621062

10631063
/// Produces a map of node public key to lightning node implementation to be used for simulations.
1064-
pub async fn ln_node_from_graph(
1064+
pub async fn ln_node_from_graph<C: Clock + std::marker::Copy>(
10651065
graph: Arc<Mutex<SimGraph>>,
10661066
routing_graph: Arc<LdkNetworkGraph>,
1067-
) -> Result<HashMap<PublicKey, Arc<Mutex<SimNode<SimGraph, SystemClock>>>>, LightningError> {
1068-
let mut nodes: HashMap<PublicKey, Arc<Mutex<SimNode<SimGraph, SystemClock>>>> = HashMap::new();
1067+
clock: C,
1068+
) -> Result<HashMap<PublicKey, Arc<Mutex<SimNode<SimGraph, C>>>>, LightningError> {
1069+
let mut nodes: HashMap<PublicKey, Arc<Mutex<SimNode<SimGraph, C>>>> = HashMap::new();
10691070

10701071
for node in graph.lock().await.nodes.iter() {
10711072
nodes.insert(
@@ -1074,7 +1075,7 @@ pub async fn ln_node_from_graph(
10741075
node.1 .0.clone(),
10751076
graph.clone(),
10761077
routing_graph.clone(),
1077-
SystemClock {},
1078+
clock.clone(),
10781079
)?)),
10791080
);
10801081
}

0 commit comments

Comments
 (0)