diff --git a/daemon/src/maker.rs b/daemon/src/maker.rs index 67e67fd..a827706 100644 --- a/daemon/src/maker.rs +++ b/daemon/src/maker.rs @@ -288,8 +288,11 @@ async fn main() -> Result<()> { tokio::spawn(maker_inc_connections_address.attach_stream(listener_stream)); tokio::spawn(wallet_sync::new(wallet, wallet_feed_sender)); + let new_order_channel = + MessageChannel::::clone_channel(&cfd_maker_actor_inbox); Ok(rocket .manage(cfd_maker_actor_inbox) + .manage(new_order_channel) .manage(cfd_feed_receiver)) }, )) diff --git a/daemon/src/routes_maker.rs b/daemon/src/routes_maker.rs index 404b55f..928e9ee 100644 --- a/daemon/src/routes_maker.rs +++ b/daemon/src/routes_maker.rs @@ -17,6 +17,7 @@ use std::borrow::Cow; use std::path::PathBuf; use tokio::select; use tokio::sync::watch; +use xtra::prelude::MessageChannel; use xtra::Address; #[rocket::get("/feed")] @@ -109,18 +110,17 @@ pub struct CfdNewOrderRequest { } #[rocket::post("/order/sell", data = "")] -pub async fn post_sell_order( +pub fn post_sell_order( order: Json, - cfd_actor_address: &State>, + new_order_channel: &State>>, _auth: Authenticated, ) -> Result, Status> { - cfd_actor_address - .do_send_async(maker_cfd::NewOrder { + new_order_channel + .do_send(maker_cfd::NewOrder { price: order.price, min_quantity: order.min_quantity, max_quantity: order.max_quantity, }) - .await .map_err(|_| Status::new(500))?; Ok(status::Accepted(None))