Box all messages in enum

The messages are very different, best to box them and save size on the
stack as an enum takes as much space on the stack than its bigger
variant.
This commit is contained in:
Franck Royer 2021-01-22 14:38:16 +11:00
parent d2a1937f51
commit a910bc2046
No known key found for this signature in database
GPG key ID: A82ED75A8DFC50A4
7 changed files with 14 additions and 14 deletions

View file

@ -45,7 +45,7 @@ pub struct Behaviour {
impl Behaviour {
/// Alice always sends her messages as a response to a request from Bob.
pub fn send(&mut self, channel: ResponseChannel<AliceToBob>, msg: SwapResponse) {
let msg = AliceToBob::SwapResponse(msg);
let msg = AliceToBob::SwapResponse(Box::new(msg));
self.rr.send_response(channel, msg);
}
@ -92,7 +92,7 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<BobToAlice, AliceToBob>>
} => {
if let BobToAlice::SwapRequest(msg) = request {
debug!("Received swap request");
self.events.push_back(OutEvent { msg, channel })
self.events.push_back(OutEvent { msg: *msg, channel })
}
}
RequestResponseEvent::Message {