Remove acknowledgements processing

We are aware of issues of timeouts when waiting for acknowledgements.
Also, to properly supports acks in a multiple swap context, we need to
revert to doing event processing on the behaviour so that we can link
leverage the `RequestResponse` libp2p behaviour and link the messages
requests ids to swap ids when receiving an ack or response.

Acks are usefully for specific scenarios where we queue a message on the
behaviour to be sent, save as sent in the DB but crash before the
message is actually sent. With acks we are able to resume the swap,
without ack, the swap will abort (refund).
This commit is contained in:
Franck Royer 2021-02-08 17:35:12 +11:00
parent cc8b855117
commit bfc19d5628
No known key found for this signature in database
GPG key ID: A82ED75A8DFC50A4
4 changed files with 5 additions and 51 deletions

View file

@ -43,7 +43,6 @@ pub struct EventLoopHandle {
dial_alice: Sender<()>,
send_swap_request: Sender<SwapRequest>,
send_encrypted_signature: Sender<EncryptedSignature>,
recv_encrypted_signature_ack: Receiver<()>,
}
impl EventLoopHandle {
@ -95,10 +94,6 @@ impl EventLoopHandle {
) -> Result<()> {
self.send_encrypted_signature.send(tx_redeem_encsig).await?;
self.recv_encrypted_signature_ack
.recv()
.await
.ok_or_else(|| anyhow!("Failed to receive encrypted signature ack from Alice"))?;
Ok(())
}
}
@ -116,7 +111,6 @@ pub struct EventLoop {
conn_established: Sender<PeerId>,
send_swap_request: Receiver<SwapRequest>,
send_encrypted_signature: Receiver<EncryptedSignature>,
recv_encrypted_signature_ack: Sender<()>,
}
impl EventLoop {
@ -144,7 +138,6 @@ impl EventLoop {
let conn_established = Channels::new();
let send_swap_request = Channels::new();
let send_encrypted_signature = Channels::new();
let recv_encrypted_signature_ack = Channels::new();
let event_loop = EventLoop {
swarm,
@ -158,7 +151,6 @@ impl EventLoop {
dial_alice: dial_alice.receiver,
send_swap_request: send_swap_request.receiver,
send_encrypted_signature: send_encrypted_signature.receiver,
recv_encrypted_signature_ack: recv_encrypted_signature_ack.sender,
};
let handle = EventLoopHandle {
@ -170,7 +162,6 @@ impl EventLoop {
dial_alice: dial_alice.sender,
send_swap_request: send_swap_request.sender,
send_encrypted_signature: send_encrypted_signature.sender,
recv_encrypted_signature_ack: recv_encrypted_signature_ack.receiver,
};
Ok((event_loop, handle))
@ -199,7 +190,6 @@ impl EventLoop {
}
OutEvent::EncryptedSignatureAcknowledged => {
debug!("Alice acknowledged encrypted signature");
let _ = self.recv_encrypted_signature_ack.send(()).await;
}
OutEvent::ResponseSent => {}
OutEvent::Failure(err) => {