diff --git a/src/machine/maker/maker.rs b/src/machine/maker/maker.rs index a586e27..3ee2aef 100644 --- a/src/machine/maker/maker.rs +++ b/src/machine/maker/maker.rs @@ -20,6 +20,7 @@ use crate::{ trade_rsp::{TradeResponse, TradeResponseBuilder, TradeResponseStatus}, }; +#[derive(Clone)] pub struct MakerAccess { tx: mpsc::Sender, } @@ -77,7 +78,7 @@ impl MakerAccess { rsp_rx.await.unwrap() } - pub async fn trade_complete(self) -> Result<(), N3xbError> { + pub async fn trade_complete(&self) -> Result<(), N3xbError> { let (rsp_tx, rsp_rx) = oneshot::channel::>(); let request = MakerRequest::TradeComplete { rsp_tx }; self.tx.send(request).await.unwrap(); @@ -127,7 +128,7 @@ impl MakerAccess { pub(crate) struct Maker { tx: mpsc::Sender, - pub task_handle: tokio::task::JoinHandle<()>, + pub(crate) task_handle: tokio::task::JoinHandle<()>, } impl Maker { diff --git a/src/machine/taker/taker.rs b/src/machine/taker/taker.rs index f4005ea..e9cdc2b 100644 --- a/src/machine/taker/taker.rs +++ b/src/machine/taker/taker.rs @@ -18,6 +18,7 @@ use crate::{ trade_rsp::{TradeResponse, TradeResponseEnvelope}, }; +#[derive(Clone)] pub struct TakerAccess { tx: mpsc::Sender, } @@ -47,7 +48,7 @@ impl TakerAccess { rsp_rx.await.unwrap() } - pub async fn trade_complete(self) -> Result<(), N3xbError> { + pub async fn trade_complete(&self) -> Result<(), N3xbError> { let (rsp_tx, rsp_rx) = oneshot::channel::>(); let request = TakerRequest::TradeComplete { rsp_tx }; self.tx.send(request).await.unwrap(); @@ -91,7 +92,7 @@ impl TakerAccess { pub(crate) struct Taker { tx: mpsc::Sender, - pub task_handle: tokio::task::JoinHandle<()>, + pub(crate) task_handle: tokio::task::JoinHandle<()>, } impl Taker { diff --git a/src/manager.rs b/src/manager.rs index d525988..5fc40d1 100644 --- a/src/manager.rs +++ b/src/manager.rs @@ -86,7 +86,7 @@ impl Manager { } // Order Management - pub async fn new_maker(&self, order: Order) -> Result { + pub async fn new_maker(&self, order: Order) -> MakerAccess { let trade_uuid = order.trade_uuid; let maker = Maker::new(self.communicator.new_accessor(), order).await; let maker_my_accessor = maker.new_accessor().await; @@ -104,7 +104,7 @@ impl Manager { let mut maker_accessors = self.maker_accessors.write().await; maker_accessors.insert(trade_uuid, maker_my_accessor); - Ok(maker_returned_accessor) + maker_returned_accessor } pub async fn query_orders( @@ -183,6 +183,4 @@ impl Manager { } Ok(()) } - - // Private Functions } diff --git a/tests/common/maker_testers.rs b/tests/common/maker_testers.rs index f532337..46dbece 100644 --- a/tests/common/maker_testers.rs +++ b/tests/common/maker_testers.rs @@ -57,7 +57,7 @@ impl MakerTesterActor { async fn run(self) { // Create and setup a Maker for a new Order let order = self.order.clone(); - let maker = self.manager.new_maker(order).await.unwrap(); + let maker = self.manager.new_maker(order).await; // Register Maker for Offer notificaitons let (offer_notif_tx, mut offer_notif_rx) =