|
@ -26,13 +26,17 @@ pub struct TakeOffer { |
|
|
pub quantity: Usd, |
|
|
pub quantity: Usd, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
pub struct ProposeSettlement { |
|
|
pub enum CfdAction { |
|
|
pub order_id: OrderId, |
|
|
ProposeSettlement { |
|
|
pub current_price: Usd, |
|
|
order_id: OrderId, |
|
|
} |
|
|
current_price: Usd, |
|
|
|
|
|
}, |
|
|
pub struct ProposeRollOver { |
|
|
ProposeRollOver { |
|
|
pub order_id: OrderId, |
|
|
order_id: OrderId, |
|
|
|
|
|
}, |
|
|
|
|
|
Commit { |
|
|
|
|
|
order_id: OrderId, |
|
|
|
|
|
}, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
pub struct MakerStreamMessage { |
|
|
pub struct MakerStreamMessage { |
|
@ -49,10 +53,6 @@ pub struct CfdRollOverCompleted { |
|
|
pub dlc: Result<Dlc>, |
|
|
pub dlc: Result<Dlc>, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
pub struct Commit { |
|
|
|
|
|
pub order_id: OrderId, |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
enum SetupState { |
|
|
enum SetupState { |
|
|
Active { |
|
|
Active { |
|
|
sender: mpsc::UnboundedSender<SetupMsg>, |
|
|
sender: mpsc::UnboundedSender<SetupMsg>, |
|
@ -610,16 +610,23 @@ impl Handler<TakeOffer> for Actor { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#[async_trait] |
|
|
#[async_trait] |
|
|
impl Handler<ProposeSettlement> for Actor { |
|
|
impl Handler<CfdAction> for Actor { |
|
|
async fn handle(&mut self, msg: ProposeSettlement, _ctx: &mut Context<Self>) { |
|
|
async fn handle(&mut self, msg: CfdAction, _ctx: &mut Context<Self>) { |
|
|
log_error!(self.handle_propose_settlement(msg.order_id, msg.current_price)); |
|
|
use CfdAction::*; |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[async_trait] |
|
|
if let Err(e) = match msg { |
|
|
impl Handler<ProposeRollOver> for Actor { |
|
|
Commit { order_id } => self.handle_commit(order_id).await, |
|
|
async fn handle(&mut self, msg: ProposeRollOver, _ctx: &mut Context<Self>) { |
|
|
ProposeSettlement { |
|
|
log_error!(self.handle_propose_roll_over(msg.order_id)); |
|
|
order_id, |
|
|
|
|
|
current_price, |
|
|
|
|
|
} => { |
|
|
|
|
|
self.handle_propose_settlement(order_id, current_price) |
|
|
|
|
|
.await |
|
|
|
|
|
} |
|
|
|
|
|
ProposeRollOver { order_id } => self.handle_propose_roll_over(order_id).await, |
|
|
|
|
|
} { |
|
|
|
|
|
tracing::error!("Message handler failed: {:#}", e); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -704,22 +711,11 @@ impl Handler<oracle::Attestation> for Actor { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#[async_trait] |
|
|
|
|
|
impl Handler<Commit> for Actor { |
|
|
|
|
|
async fn handle(&mut self, msg: Commit, _ctx: &mut Context<Self>) { |
|
|
|
|
|
log_error!(self.handle_commit(msg.order_id)) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl Message for TakeOffer { |
|
|
impl Message for TakeOffer { |
|
|
type Result = (); |
|
|
type Result = (); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
impl Message for ProposeSettlement { |
|
|
impl Message for CfdAction { |
|
|
type Result = (); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl Message for ProposeRollOver { |
|
|
|
|
|
type Result = (); |
|
|
type Result = (); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -736,8 +732,4 @@ impl Message for CfdRollOverCompleted { |
|
|
type Result = (); |
|
|
type Result = (); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
impl Message for Commit { |
|
|
|
|
|
type Result = (); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl xtra::Actor for Actor {} |
|
|
impl xtra::Actor for Actor {} |
|
|