luckysori
3 years ago
committed by
Lucas Soriano del Pino
No known key found for this signature in database
GPG Key ID: 89CE0DB40A19D524
3 changed files with
20 additions and
14 deletions
-
daemon/src/address_map.rs
-
daemon/src/connection.rs
-
daemon/src/maker_cfd.rs
|
|
@ -46,7 +46,7 @@ where |
|
|
|
} |
|
|
|
|
|
|
|
/// Sends a message to the actor stored with the given key.
|
|
|
|
pub async fn send<M>(&self, key: &K, msg: M) -> bool |
|
|
|
pub async fn send<M>(&self, key: &K, msg: M) -> Result<(), NotConnected> |
|
|
|
where |
|
|
|
M: Message<Result = ()>, |
|
|
|
A: Handler<M>, |
|
|
@ -56,15 +56,17 @@ where |
|
|
|
addr.send(msg) |
|
|
|
.await |
|
|
|
.expect("we checked that we are connected"); |
|
|
|
|
|
|
|
true |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
Some(_) => false, |
|
|
|
None => false, |
|
|
|
_ => Err(NotConnected), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#[derive(thiserror::Error, Debug)] |
|
|
|
#[error("Receiving actor is down")] |
|
|
|
pub struct NotConnected; |
|
|
|
|
|
|
|
/// A message to notify that an actor instance is stopping.
|
|
|
|
pub struct Stopping<A> { |
|
|
|
pub me: Address<A>, |
|
|
|
|
|
@ -369,7 +369,12 @@ impl Actor { |
|
|
|
} |
|
|
|
} |
|
|
|
wire::MakerToTaker::Settlement { order_id, msg } => { |
|
|
|
if !self.collab_settlement_actors.send(&order_id, msg).await { |
|
|
|
if self |
|
|
|
.collab_settlement_actors |
|
|
|
.send(&order_id, msg) |
|
|
|
.await |
|
|
|
.is_err() |
|
|
|
{ |
|
|
|
tracing::warn!(%order_id, "No active collaborative settlement"); |
|
|
|
} |
|
|
|
} |
|
|
@ -377,28 +382,30 @@ impl Actor { |
|
|
|
order_id, |
|
|
|
oracle_event_id, |
|
|
|
} => { |
|
|
|
if !self |
|
|
|
if self |
|
|
|
.rollover_actors |
|
|
|
.send( |
|
|
|
&order_id, |
|
|
|
rollover_taker::RollOverAccepted { oracle_event_id }, |
|
|
|
) |
|
|
|
.await |
|
|
|
.is_err() |
|
|
|
{ |
|
|
|
tracing::warn!(%order_id, "No active rollover"); |
|
|
|
} |
|
|
|
} |
|
|
|
wire::MakerToTaker::RejectRollOver(order_id) => { |
|
|
|
if !self |
|
|
|
if self |
|
|
|
.rollover_actors |
|
|
|
.send(&order_id, rollover_taker::RollOverRejected) |
|
|
|
.await |
|
|
|
.is_err() |
|
|
|
{ |
|
|
|
tracing::warn!(%order_id, "No active rollover"); |
|
|
|
} |
|
|
|
} |
|
|
|
wire::MakerToTaker::RollOverProtocol { order_id, msg } => { |
|
|
|
if !self.rollover_actors.send(&order_id, msg).await { |
|
|
|
if self.rollover_actors.send(&order_id, msg).await.is_err() { |
|
|
|
tracing::warn!(%order_id, "No active rollover"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
@ -523,13 +523,10 @@ impl<O, M, T, W> Actor<O, M, T, W> { |
|
|
|
let mut conn = self.db.acquire().await?; |
|
|
|
let mut cfd = load_cfd_by_order_id(order_id, &mut conn).await?; |
|
|
|
|
|
|
|
if !self |
|
|
|
.setup_actors |
|
|
|
self.setup_actors |
|
|
|
.send(&order_id, setup_maker::Accepted) |
|
|
|
.await |
|
|
|
{ |
|
|
|
anyhow::bail!("No active contract setup for order {}", order_id); |
|
|
|
} |
|
|
|
.with_context(|| format!("No active contract setup for order {}", order_id))?; |
|
|
|
|
|
|
|
cfd.state = CfdState::contract_setup(); |
|
|
|
append_cfd_state(&cfd, &mut conn, &self.projection_actor).await?; |
|
|
|