Browse Source

Associate contract setup messages with an order ID

This is the first step in allowing concurrent execution of contract
setup for different CFDs.
debug-collab-settlement
Lucas Soriano del Pino 3 years ago
parent
commit
2f2ab75b75
No known key found for this signature in database GPG Key ID: EE611E973A1530E7
  1. 4
      daemon/src/maker_cfd.rs
  2. 6
      daemon/src/taker_cfd.rs
  3. 14
      daemon/src/wire.rs

4
daemon/src/maker_cfd.rs

@ -538,7 +538,7 @@ where
self.takers.clone().into_sink().with(move |msg| {
future::ok(maker_inc_connections::TakerMessage {
taker_id,
msg: wire::MakerToTaker::Protocol(msg),
msg: wire::MakerToTaker::Protocol { order_id, msg },
})
}),
receiver,
@ -1133,7 +1133,7 @@ where
} => {
log_error!(self.handle_initiate_settlement(taker_id, order_id, sig_taker))
}
wire::TakerToMaker::Protocol(msg) => {
wire::TakerToMaker::Protocol { msg, .. } => {
log_error!(self.handle_inc_protocol_msg(taker_id, msg))
}
wire::TakerToMaker::ProposeRollOver {

6
daemon/src/taker_cfd.rs

@ -483,7 +483,7 @@ where
self.send_to_maker
.sink()
.clone_message_sink()
.with(|msg| future::ok(wire::TakerToMaker::Protocol(msg))),
.with(move |msg| future::ok(wire::TakerToMaker::Protocol { order_id, msg })),
receiver,
(self.oracle_pk, offer_announcement),
SetupParams::new(
@ -755,8 +755,8 @@ where
wire::MakerToTaker::InvalidOrderId(order_id) => {
log_error!(self.handle_invalid_order_id(order_id))
}
wire::MakerToTaker::Protocol(setup_msg) => {
log_error!(self.handle_inc_protocol_msg(setup_msg))
wire::MakerToTaker::Protocol { msg, .. } => {
log_error!(self.handle_inc_protocol_msg(msg))
}
wire::MakerToTaker::ConfirmRollOver {
order_id,

14
daemon/src/wire.rs

@ -43,7 +43,10 @@ pub enum TakerToMaker {
order_id: OrderId,
timestamp: Timestamp,
},
Protocol(SetupMsg),
Protocol {
order_id: OrderId,
msg: SetupMsg,
},
RollOverProtocol(RollOverMsg),
}
@ -53,7 +56,7 @@ impl fmt::Display for TakerToMaker {
TakerToMaker::TakeOrder { .. } => write!(f, "TakeOrder"),
TakerToMaker::ProposeSettlement { .. } => write!(f, "ProposeSettlement"),
TakerToMaker::InitiateSettlement { .. } => write!(f, "InitiateSettlement"),
TakerToMaker::Protocol(_) => write!(f, "Protocol"),
TakerToMaker::Protocol { .. } => write!(f, "Protocol"),
TakerToMaker::ProposeRollOver { .. } => write!(f, "ProposeRollOver"),
TakerToMaker::RollOverProtocol(_) => write!(f, "RollOverProtocol"),
}
@ -72,7 +75,10 @@ pub enum MakerToTaker {
ConfirmSettlement(OrderId),
RejectSettlement(OrderId),
InvalidOrderId(OrderId),
Protocol(SetupMsg),
Protocol {
order_id: OrderId,
msg: SetupMsg,
},
RollOverProtocol(RollOverMsg),
ConfirmRollOver {
order_id: OrderId,
@ -91,7 +97,7 @@ impl fmt::Display for MakerToTaker {
MakerToTaker::ConfirmSettlement(_) => write!(f, "ConfirmSettlement"),
MakerToTaker::RejectSettlement(_) => write!(f, "RejectSettlement"),
MakerToTaker::InvalidOrderId(_) => write!(f, "InvalidOrderId"),
MakerToTaker::Protocol(_) => write!(f, "Protocol"),
MakerToTaker::Protocol { .. } => write!(f, "Protocol"),
MakerToTaker::ConfirmRollOver { .. } => write!(f, "ConfirmRollOver"),
MakerToTaker::RejectRollOver(_) => write!(f, "RejectRollOver"),
MakerToTaker::RollOverProtocol(_) => write!(f, "RollOverProtocol"),

Loading…
Cancel
Save