diff --git a/daemon/src/monitor.rs b/daemon/src/monitor.rs index 452eb23..eb57111 100644 --- a/daemon/src/monitor.rs +++ b/daemon/src/monitor.rs @@ -11,6 +11,7 @@ use std::collections::hash_map::Entry; use std::collections::{BTreeMap, HashMap}; use std::convert::{TryFrom, TryInto}; use std::fmt; +use std::marker::Send; use std::ops::{Add, RangeInclusive}; const FINALITY_CONFIRMATIONS: u32 = 1; @@ -30,20 +31,20 @@ pub struct MonitorParams { pub struct Sync; -pub struct Actor +pub struct Actor where T: xtra::Actor, { cfds: HashMap, cfd_actor_addr: xtra::Address, - client: bdk::electrum_client::Client, + client: C, latest_block_height: BlockHeight, current_status: BTreeMap<(Txid, Script), ScriptStatus>, awaiting_status: HashMap<(Txid, Script), Vec<(ScriptStatus, Event)>>, } -impl Actor +impl Actor where T: xtra::Actor + xtra::Handler, { @@ -135,7 +136,13 @@ where Ok(actor) } +} +impl Actor +where + T: xtra::Actor + xtra::Handler, + C: bdk::electrum_client::ElectrumApi, +{ fn monitor_all(&mut self, params: &MonitorParams, order_id: OrderId) { self.monitor_lock_finality(params, order_id); self.monitor_commit_finality(params, order_id); @@ -477,12 +484,19 @@ impl xtra::Message for Sync { type Result = (); } -impl xtra::Actor for Actor where T: xtra::Actor {} +impl xtra::Actor for Actor +where + T: xtra::Actor, + C: Send, + C: 'static, +{ +} #[async_trait] -impl xtra::Handler for Actor +impl xtra::Handler for Actor where T: xtra::Actor + xtra::Handler, + C: bdk::electrum_client::ElectrumApi + Send + 'static, { async fn handle(&mut self, msg: StartMonitoring, _ctx: &mut xtra::Context) { let StartMonitoring { id, params } = msg; @@ -492,9 +506,10 @@ where } } #[async_trait] -impl xtra::Handler for Actor +impl xtra::Handler for Actor where T: xtra::Actor + xtra::Handler, + C: bdk::electrum_client::ElectrumApi + Send + 'static, { async fn handle(&mut self, _: Sync, _ctx: &mut xtra::Context) { log_error!(self.sync());