Browse Source

Remove error case from updating projection

Not finding a proposal for a specific error does not need to be
bubbled up to the caller.
no-buy-button-while-setting-up-cfd
Thomas Eizinger 3 years ago
parent
commit
dd374474e9
No known key found for this signature in database GPG Key ID: 651AC83A6C6C8B96
  1. 8
      daemon/src/maker_cfd.rs
  2. 38
      daemon/src/projection.rs
  3. 8
      daemon/src/taker_cfd.rs

8
daemon/src/maker_cfd.rs

@ -187,7 +187,7 @@ impl<O, M, T, W> Actor<O, M, T, W> {
.insert(proposal.order_id, (new_proposal.clone(), taker_id));
self.projection_actor
.send(try_into_update_rollover_proposal(new_proposal)?)
.await??;
.await?;
Ok(())
}
@ -211,7 +211,7 @@ impl<O, M, T, W> Actor<O, M, T, W> {
.insert(proposal.order_id, (new_proposal.clone(), taker_id));
self.projection_actor
.send(try_into_update_settlement_proposal(new_proposal)?)
.await??;
.await?;
Ok(())
}
@ -269,7 +269,7 @@ impl<O, M, T, W> Actor<O, M, T, W> {
order: *order_id,
proposal: None,
})
.await??
.await?
}
UpdateCfdProposal::RollOverProposal { .. } => {
self.projection_actor
@ -277,7 +277,7 @@ impl<O, M, T, W> Actor<O, M, T, W> {
order: *order_id,
proposal: None,
})
.await??
.await?
}
}
} else {

38
daemon/src/projection.rs

@ -115,12 +115,12 @@ impl State {
temp.into()
}
pub fn amend_settlement_proposal(&mut self, proposal: UpdateSettlementProposal) -> Result<()> {
pub fn amend_settlement_proposal(&mut self, proposal: UpdateSettlementProposal) {
let order = proposal.order;
self.amend_cfd_proposal(order, proposal.into())
}
pub fn amend_rollover_proposal(&mut self, proposal: UpdateRollOverProposal) -> Result<()> {
pub fn amend_rollover_proposal(&mut self, proposal: UpdateRollOverProposal) {
let order = proposal.order;
self.amend_cfd_proposal(order, proposal.into())
}
@ -133,21 +133,21 @@ impl State {
let _ = std::mem::replace(&mut self.cfds, cfds);
}
fn amend_cfd_proposal(
&mut self,
order: OrderId,
proposal: Option<UpdateCfdProposal>,
) -> Result<()> {
fn amend_cfd_proposal(&mut self, order: OrderId, proposal: Option<UpdateCfdProposal>) {
if let Some(proposal) = proposal {
self.proposals.insert(order, proposal);
tracing::trace!(%order, "Cfd proposal got updated");
} else {
if self.proposals.remove(&order).is_none() {
anyhow::bail!("Could not find proposal with order id: {}", &order)
}
tracing::trace!(%order, "Removed cfd proposal");
};
Ok(())
return;
}
if self.proposals.remove(&order).is_none() {
tracing::trace!(%order, "Cannot remove cfd proposal: unknown");
return;
}
tracing::trace!(%order, "Removed cfd proposal");
}
}
@ -172,15 +172,13 @@ impl Actor {
.connected_takers
.send(msg.0.iter().map(|x| x.into()).collect_vec());
}
fn handle(&mut self, msg: UpdateSettlementProposal) -> Result<()> {
self.state.amend_settlement_proposal(msg)?;
fn handle(&mut self, msg: UpdateSettlementProposal) {
self.state.amend_settlement_proposal(msg);
let _ = self.tx.cfds.send(self.state.to_cfds());
Ok(())
}
fn handle(&mut self, msg: UpdateRollOverProposal) -> Result<()> {
self.state.amend_rollover_proposal(msg)?;
fn handle(&mut self, msg: UpdateRollOverProposal) {
self.state.amend_rollover_proposal(msg);
let _ = self.tx.cfds.send(self.state.to_cfds());
Ok(())
}
}

8
daemon/src/taker_cfd.rs

@ -122,7 +122,7 @@ impl<O, M, W> Actor<O, M, W> {
order: *order_id,
proposal: None,
})
.await??
.await?
}
UpdateCfdProposal::RollOverProposal { .. } => {
self.projection_actor
@ -130,7 +130,7 @@ impl<O, M, W> Actor<O, M, W> {
order: *order_id,
proposal: None,
})
.await??
.await?
}
}
} else {
@ -188,7 +188,7 @@ where
.insert(proposal.order_id, new_proposal.clone());
self.projection_actor
.send(try_into_update_rollover_proposal(new_proposal)?)
.await??;
.await?;
self.conn_actor
.send(wire::TakerToMaker::ProposeRollOver {
@ -240,7 +240,7 @@ impl<O, M, W> Actor<O, M, W> {
.insert(proposal.order_id, new_proposal.clone());
self.projection_actor
.send(try_into_update_settlement_proposal(new_proposal)?)
.await??;
.await?;
self.conn_actor
.send(wire::TakerToMaker::ProposeSettlement {

Loading…
Cancel
Save