Skip to content

Commit c4a6fa9

Browse files
committed
multi: include Send in LightningNode trait as supertrait
1 parent 01c31ec commit c4a6fa9

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

sim-cli/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ async fn main() -> anyhow::Result<()> {
9292
serde_json::from_str(&std::fs::read_to_string(sim_path)?)
9393
.map_err(|e| anyhow!("Could not deserialize node connection data or activity description from simulation file (line {}, col {}).", e.line(), e.column()))?;
9494

95-
let mut clients: HashMap<PublicKey, Arc<Mutex<dyn LightningNode + Send>>> = HashMap::new();
95+
let mut clients: HashMap<PublicKey, Arc<Mutex<dyn LightningNode>>> = HashMap::new();
9696
let mut pk_node_map = HashMap::new();
9797
let mut alias_node_map = HashMap::new();
9898

9999
for connection in nodes {
100100
// TODO: Feels like there should be a better way of doing this without having to Arc<Mutex<T>>> it at this time.
101101
// Box sort of works, but we won't know the size of the dyn LightningNode at compile time so the compiler will
102102
// scream at us when trying to create the Arc<Mutex>> later on while adding the node to the clients map
103-
let node: Arc<Mutex<dyn LightningNode + Send>> = match connection {
103+
let node: Arc<Mutex<dyn LightningNode>> = match connection {
104104
NodeConnection::LND(c) => Arc::new(Mutex::new(LndNode::new(c).await?)),
105105
NodeConnection::CLN(c) => Arc::new(Mutex::new(ClnNode::new(c).await?)),
106106
};

sim-lib/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl Display for NodeInfo {
179179

180180
/// LightningNode represents the functionality that is required to execute events on a lightning node.
181181
#[async_trait]
182-
pub trait LightningNode {
182+
pub trait LightningNode: Send {
183183
/// Get information about the node.
184184
fn get_info(&self) -> &NodeInfo;
185185
/// Get the network this node is running at
@@ -325,7 +325,7 @@ enum SimulationOutput {
325325
#[derive(Clone)]
326326
pub struct Simulation {
327327
// The lightning node that is being simulated.
328-
nodes: HashMap<PublicKey, Arc<Mutex<dyn LightningNode + Send>>>,
328+
nodes: HashMap<PublicKey, Arc<Mutex<dyn LightningNode>>>,
329329
// The activity that are to be executed on the node.
330330
activity: Vec<ActivityDefinition>,
331331
// High level triggers used to manage simulation tasks and shutdown.
@@ -362,7 +362,7 @@ struct ExecutorKit {
362362

363363
impl Simulation {
364364
pub fn new(
365-
nodes: HashMap<PublicKey, Arc<Mutex<dyn LightningNode + Send>>>,
365+
nodes: HashMap<PublicKey, Arc<Mutex<dyn LightningNode>>>,
366366
activity: Vec<ActivityDefinition>,
367367
total_time: Option<u32>,
368368
expected_payment_msat: u64,
@@ -722,7 +722,7 @@ impl Simulation {
722722
// expect the senders corresponding to our receiver to be dropped, which will cause the receiver to error out and
723723
// exit.
724724
async fn consume_events(
725-
node: Arc<Mutex<dyn LightningNode + Send>>,
725+
node: Arc<Mutex<dyn LightningNode>>,
726726
mut receiver: Receiver<SimulationEvent>,
727727
sender: Sender<SimulationOutput>,
728728
shutdown: Trigger,
@@ -986,7 +986,7 @@ async fn run_results_logger(
986986
/// out. In the multiple-producer case, a single producer shutting down does not drop *all* sending channels so the
987987
/// consumer will not exit and a trigger is required.
988988
async fn produce_simulation_results(
989-
nodes: HashMap<PublicKey, Arc<Mutex<dyn LightningNode + Send>>>,
989+
nodes: HashMap<PublicKey, Arc<Mutex<dyn LightningNode>>>,
990990
mut output_receiver: Receiver<SimulationOutput>,
991991
results: Sender<(Payment, PaymentResult)>,
992992
shutdown: Listener,
@@ -1034,7 +1034,7 @@ async fn produce_simulation_results(
10341034
}
10351035

10361036
async fn track_payment_result(
1037-
node: Arc<Mutex<dyn LightningNode + Send>>,
1037+
node: Arc<Mutex<dyn LightningNode>>,
10381038
results: Sender<(Payment, PaymentResult)>,
10391039
payment: Payment,
10401040
shutdown: Listener,

0 commit comments

Comments
 (0)