Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sim-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ futures = "0.3.30"
console-subscriber = { version = "0.4.0", optional = true}
tokio-util = { version = "0.7.13", features = ["rt"] }
openssl = { version = "0.10", features = ["vendored"] }
lightning = { version = "0.0.123" }

[features]
dev = ["console-subscriber"]
19 changes: 14 additions & 5 deletions sim-cli/src/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ use log::LevelFilter;
use serde::{Deserialize, Serialize};
use simln_lib::clock::SimulationClock;
use simln_lib::sim_node::{
ln_node_from_graph, populate_network_graph, ChannelPolicy, CustomRecords, Interceptor,
SimGraph, SimNode, SimulatedChannel,
ln_node_from_graph, populate_network_graph, ChannelPolicy, CustomRecords, DefaultPathFinder,
Interceptor, SimGraph, SimulatedChannel,
};

use simln_lib::{
cln, cln::ClnNode, eclair, eclair::EclairNode, lnd, lnd::LndNode, serializers,
ActivityDefinition, Amount, Interval, LightningError, LightningNode, NodeId, NodeInfo,
Expand Down Expand Up @@ -262,7 +263,7 @@ pub async fn create_simulation_with_network(
(
Simulation<SimulationClock>,
Vec<ActivityDefinition>,
HashMap<PublicKey, Arc<Mutex<SimNode<SimGraph, SimulationClock>>>>,
HashMap<PublicKey, Arc<Mutex<dyn LightningNode>>>,
),
anyhow::Error,
> {
Expand Down Expand Up @@ -309,19 +310,27 @@ pub async fn create_simulation_with_network(
.map_err(|e| SimulationError::SimulatedNetworkError(format!("{:?}", e)))?,
);

// Create the pathfinder instance
let pathfinder = DefaultPathFinder::new(routing_graph.clone());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not pass the pathfinder to create_simulation_with_network? there should be a way to create a simulation with a custom one.


// We want the full set of nodes in our graph to return to the caller so that they can take
// custom actions on the simulated network. For the nodes we'll pass our simulation, cast them
// to a dyn trait and exclude any nodes that shouldn't be included in random activity
// generation.
let nodes = ln_node_from_graph(simulation_graph.clone(), routing_graph, clock.clone()).await?;
let nodes = ln_node_from_graph(
simulation_graph.clone(),
routing_graph,
clock.clone(),
pathfinder,
)
.await?;
let mut nodes_dyn: HashMap<_, Arc<Mutex<dyn LightningNode>>> = nodes
.iter()
.map(|(pk, node)| (*pk, Arc::clone(node) as Arc<Mutex<dyn LightningNode>>))
.collect();
for pk in exclude {
nodes_dyn.remove(pk);
}

let validated_activities =
get_validated_activities(&nodes_dyn, nodes_info, sim_params.activity.clone()).await?;

Expand Down
Loading