From a0f0e286e47e64a99e0466b68dc8361964b6d702 Mon Sep 17 00:00:00 2001 From: Carla Kirk-Cohen Date: Wed, 24 Jan 2024 12:05:50 -0500 Subject: [PATCH] multi: include Send in LightningNode trait as supertrait --- sim-cli/src/main.rs | 4 ++-- sim-lib/src/lib.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sim-cli/src/main.rs b/sim-cli/src/main.rs index ac923ae9..545a5104 100644 --- a/sim-cli/src/main.rs +++ b/sim-cli/src/main.rs @@ -92,7 +92,7 @@ async fn main() -> anyhow::Result<()> { serde_json::from_str(&std::fs::read_to_string(sim_path)?) .map_err(|e| anyhow!("Could not deserialize node connection data or activity description from simulation file (line {}, col {}).", e.line(), e.column()))?; - let mut clients: HashMap>> = HashMap::new(); + let mut clients: HashMap>> = HashMap::new(); let mut pk_node_map = HashMap::new(); let mut alias_node_map = HashMap::new(); @@ -100,7 +100,7 @@ async fn main() -> anyhow::Result<()> { // TODO: Feels like there should be a better way of doing this without having to Arc>> it at this time. // Box sort of works, but we won't know the size of the dyn LightningNode at compile time so the compiler will // scream at us when trying to create the Arc> later on while adding the node to the clients map - let node: Arc> = match connection { + let node: Arc> = match connection { NodeConnection::LND(c) => Arc::new(Mutex::new(LndNode::new(c).await?)), NodeConnection::CLN(c) => Arc::new(Mutex::new(ClnNode::new(c).await?)), }; diff --git a/sim-lib/src/lib.rs b/sim-lib/src/lib.rs index 7cc63706..1e747d62 100644 --- a/sim-lib/src/lib.rs +++ b/sim-lib/src/lib.rs @@ -179,7 +179,7 @@ impl Display for NodeInfo { /// LightningNode represents the functionality that is required to execute events on a lightning node. #[async_trait] -pub trait LightningNode { +pub trait LightningNode: Send { /// Get information about the node. fn get_info(&self) -> &NodeInfo; /// Get the network this node is running at @@ -325,7 +325,7 @@ enum SimulationOutput { #[derive(Clone)] pub struct Simulation { // The lightning node that is being simulated. - nodes: HashMap>>, + nodes: HashMap>>, // The activity that are to be executed on the node. activity: Vec, // High level triggers used to manage simulation tasks and shutdown. @@ -362,7 +362,7 @@ struct ExecutorKit { impl Simulation { pub fn new( - nodes: HashMap>>, + nodes: HashMap>>, activity: Vec, total_time: Option, expected_payment_msat: u64, @@ -727,7 +727,7 @@ impl Simulation { // expect the senders corresponding to our receiver to be dropped, which will cause the receiver to error out and // exit. async fn consume_events( - node: Arc>, + node: Arc>, mut receiver: Receiver, sender: Sender, shutdown: Trigger, @@ -989,7 +989,7 @@ async fn run_results_logger( /// out. In the multiple-producer case, a single producer shutting down does not drop *all* sending channels so the /// consumer will not exit and a trigger is required. async fn produce_simulation_results( - nodes: HashMap>>, + nodes: HashMap>>, mut output_receiver: Receiver, results: Sender<(Payment, PaymentResult)>, shutdown: Listener, @@ -1037,7 +1037,7 @@ async fn produce_simulation_results( } async fn track_payment_result( - node: Arc>, + node: Arc>, results: Sender<(Payment, PaymentResult)>, payment: Payment, shutdown: Listener,