diff --git a/daemon/src/monitor.rs b/daemon/src/monitor.rs index 0221557..4b8e345 100644 --- a/daemon/src/monitor.rs +++ b/daemon/src/monitor.rs @@ -15,6 +15,7 @@ use std::fmt; use std::marker::Send; use std::ops::{Add, RangeInclusive}; use xtra::prelude::StrongMessageChannel; +use xtra_productivity::xtra_productivity; const FINALITY_CONFIRMATIONS: u32 = 1; @@ -320,16 +321,6 @@ where Ok(()) } - fn handle_collaborative_settlement( - &mut self, - collaborative_settlement: CollaborativeSettlement, - ) { - self.monitor_close_finality( - collaborative_settlement.tx, - collaborative_settlement.order_id, - ); - } - async fn update_state( &mut self, latest_block_height: BlockHeight, @@ -530,14 +521,6 @@ impl Add for BlockHeight { } } -impl xtra::Message for StartMonitoring { - type Result = (); -} - -impl xtra::Message for CollaborativeSettlement { - type Result = (); -} - #[derive(Debug, Clone, PartialEq)] pub enum Event { LockFinality(OrderId), @@ -630,17 +613,31 @@ impl xtra::Message for Sync { impl xtra::Actor for Actor where C: Send + 'static {} -#[async_trait] -impl xtra::Handler for Actor +#[xtra_productivity] +impl Actor where C: bdk::electrum_client::ElectrumApi + Send + 'static, { - async fn handle(&mut self, msg: StartMonitoring, _ctx: &mut xtra::Context) { + async fn handle_start_monitoring( + &mut self, + msg: StartMonitoring, + _ctx: &mut xtra::Context, + ) { let StartMonitoring { id, params } = msg; self.monitor_all(¶ms, id); self.cfds.insert(id, params); } + + fn handle_collaborative_settlement( + &mut self, + collaborative_settlement: CollaborativeSettlement, + ) { + self.monitor_close_finality( + collaborative_settlement.tx, + collaborative_settlement.order_id, + ); + } } #[async_trait] impl xtra::Handler for Actor @@ -659,16 +656,6 @@ impl xtra::Handler for Actor { } } -#[async_trait] -impl xtra::Handler for Actor -where - C: bdk::electrum_client::ElectrumApi + Send + 'static, -{ - async fn handle(&mut self, msg: CollaborativeSettlement, _ctx: &mut xtra::Context) { - self.handle_collaborative_settlement(msg); - } -} - #[cfg(test)] mod tests { use super::*;