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

@ -7,10 +7,8 @@ use crate::protocol::alice::TransferProof;
use crate::{bitcoin, monero};
use anyhow::{bail, Context, Result};
use futures::pin_mut;
use libp2p::PeerId;
pub async fn lock_xmr(
bob_peer_id: PeerId,
state3: alice::State3,
event_loop_handle: &mut EventLoopHandle,
monero_wallet: &monero::Wallet,
@ -30,7 +28,7 @@ pub async fn lock_xmr(
// Otherwise Alice might publish the lock tx twice!
event_loop_handle
.send_transfer_proof(bob_peer_id, TransferProof {
.send_transfer_proof(TransferProof {
tx_lock_proof: transfer_proof,
})
.await?;