Properly handle concurrent messages to and from peers

Previously, we were forwarding incoming messages from peers to all
swaps that were currently running. That is obviously wrong. The new
design scopes an `EventLoopHandle` to a specific PeerId to avoid
this problem.
This commit is contained in:
Thomas Eizinger 2021-03-17 14:39:54 +11:00
parent 95acbc6277
commit a57f88d1b4
No known key found for this signature in database
GPG key ID: 651AC83A6C6C8B96
9 changed files with 98 additions and 157 deletions

View file

@ -32,6 +32,7 @@ pub enum OutEvent {
EncryptedSignature {
msg: Box<EncryptedSignature>,
channel: ResponseChannel<()>,
peer: PeerId,
},
ResponseSent, // Same variant is used for all messages as no processing is done
Failure(Error),
@ -140,9 +141,10 @@ impl From<encrypted_signature::OutEvent> for OutEvent {
fn from(event: encrypted_signature::OutEvent) -> Self {
use crate::protocol::alice::encrypted_signature::OutEvent::*;
match event {
MsgReceived { msg, channel } => OutEvent::EncryptedSignature {
MsgReceived { msg, channel, peer } => OutEvent::EncryptedSignature {
msg: Box::new(msg),
channel,
peer,
},
AckSent => OutEvent::ResponseSent,
Failure(err) => OutEvent::Failure(err.context("Failure with Encrypted Signature")),