From ecb54958ee10404245ff2120026c4c246a912276 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Thu, 4 Feb 2021 11:38:06 +1100 Subject: [PATCH] Preemptively Box few messages --- swap/src/protocol/alice.rs | 11 +++++++---- swap/src/protocol/alice/event_loop.rs | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/swap/src/protocol/alice.rs b/swap/src/protocol/alice.rs index 1c95eb19..b1585fc2 100644 --- a/swap/src/protocol/alice.rs +++ b/swap/src/protocol/alice.rs @@ -230,7 +230,7 @@ pub enum OutEvent { channel: ResponseChannel, }, Message1 { - msg: bob::Message1, + msg: Box, channel: ResponseChannel, }, Message2 { @@ -239,7 +239,7 @@ pub enum OutEvent { }, ExecutionSetupDone(Result>), TransferProofAcknowledged, - EncryptedSignature(EncryptedSignature), + EncryptedSignature(Box), } impl From for OutEvent { @@ -272,7 +272,10 @@ impl From for OutEvent { impl From for OutEvent { fn from(event: message1::OutEvent) -> Self { match event { - message1::OutEvent::Msg { msg, channel } => OutEvent::Message1 { msg, channel }, + message1::OutEvent::Msg { msg, channel } => OutEvent::Message1 { + msg: Box::new(msg), + channel, + }, } } } @@ -307,7 +310,7 @@ impl From for OutEvent { impl From for OutEvent { fn from(event: encrypted_signature::OutEvent) -> Self { match event { - encrypted_signature::OutEvent::Msg(msg) => OutEvent::EncryptedSignature(msg), + encrypted_signature::OutEvent::Msg(msg) => OutEvent::EncryptedSignature(Box::new(msg)), } } } diff --git a/swap/src/protocol/alice/event_loop.rs b/swap/src/protocol/alice/event_loop.rs index 685f4606..bc2bea31 100644 --- a/swap/src/protocol/alice/event_loop.rs +++ b/swap/src/protocol/alice/event_loop.rs @@ -244,7 +244,7 @@ impl EventLoop { let _ = self.recv_message0.send((*msg, channel)).await; } OutEvent::Message1 { msg, channel } => { - let _ = self.recv_message1.send((msg, channel)).await; + let _ = self.recv_message1.send((*msg, channel)).await; } OutEvent::Message2 { msg, bob_peer_id : _} => { let _ = self.recv_message2.send(*msg).await; @@ -257,7 +257,7 @@ impl EventLoop { let _ = self.recv_transfer_proof_ack.send(()).await; } OutEvent::EncryptedSignature(msg) => { - let _ = self.recv_encrypted_signature.send(msg).await; + let _ = self.recv_encrypted_signature.send(*msg).await; } OutEvent::Request(event) => { let _ = self.request.send(*event).await;