Browse Source

Merge #380

380: Treat `InvalidOrderId` from maker as `Rejected` r=luckysori a=luckysori

If the maker tells the taker that the take request was for an invalid order ID, we should do something other than panic. For example,
logging and treating the situation as if the maker had rejected the take request.

Co-authored-by: Lucas Soriano del Pino <l.soriano.del.pino@gmail.com>
debug-statements
bors[bot] 3 years ago
committed by GitHub
parent
commit
08b3d89981
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 31
      daemon/src/taker_cfd.rs

31
daemon/src/taker_cfd.rs

@ -202,13 +202,7 @@ impl<O, M> Actor<O, M> {
} }
async fn handle_order_rejected(&mut self, order_id: OrderId) -> Result<()> { async fn handle_order_rejected(&mut self, order_id: OrderId) -> Result<()> {
tracing::debug!(%order_id, "Order rejected"); self.append_cfd_state_rejected(order_id).await?;
let mut conn = self.db.acquire().await?;
let mut cfd = load_cfd_by_order_id(order_id, &mut conn).await?;
cfd.state = CfdState::rejected();
append_cfd_state(&cfd, &mut conn, &self.cfd_feed_actor_inbox).await?;
Ok(()) Ok(())
} }
@ -291,6 +285,25 @@ impl<O, M> Actor<O, M> {
.await?; .await?;
Ok(()) Ok(())
} }
async fn handle_invalid_order_id(&mut self, order_id: OrderId) -> Result<()> {
tracing::debug!(%order_id, "Invalid order ID");
self.append_cfd_state_rejected(order_id).await?;
Ok(())
}
async fn append_cfd_state_rejected(&mut self, order_id: OrderId) -> Result<()> {
tracing::debug!(%order_id, "Order rejected");
let mut conn = self.db.acquire().await?;
let mut cfd = load_cfd_by_order_id(order_id, &mut conn).await?;
cfd.state = CfdState::rejected();
append_cfd_state(&cfd, &mut conn, &self.cfd_feed_actor_inbox).await?;
Ok(())
}
} }
impl<O, M> Actor<O, M> impl<O, M> Actor<O, M>
@ -678,7 +691,9 @@ where
wire::MakerToTaker::RejectSettlement(order_id) => { wire::MakerToTaker::RejectSettlement(order_id) => {
log_error!(self.handle_settlement_rejected(order_id)) log_error!(self.handle_settlement_rejected(order_id))
} }
wire::MakerToTaker::InvalidOrderId(_) => todo!(), wire::MakerToTaker::InvalidOrderId(order_id) => {
log_error!(self.handle_invalid_order_id(order_id))
}
wire::MakerToTaker::Protocol(setup_msg) => { wire::MakerToTaker::Protocol(setup_msg) => {
log_error!(self.handle_inc_protocol_msg(setup_msg)) log_error!(self.handle_inc_protocol_msg(setup_msg))
} }

Loading…
Cancel
Save