mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-05-20 15:40:48 -04:00
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:
parent
95acbc6277
commit
a57f88d1b4
9 changed files with 98 additions and 157 deletions
|
@ -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?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue