mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-25 15:39:25 -05:00
Prevent future from being stopped by calling forget on handle
This commit is contained in:
parent
77ec7e502f
commit
2ced9ddba4
@ -20,8 +20,8 @@ use libp2p::{
|
|||||||
};
|
};
|
||||||
use rand::rngs::OsRng;
|
use rand::rngs::OsRng;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::{broadcast, mpsc};
|
use tokio::sync::{broadcast, mpsc, mpsc::error::SendError};
|
||||||
use tracing::{debug, error, trace, warn};
|
use tracing::{debug, error, trace};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
// TODO: Use dynamic
|
// TODO: Use dynamic
|
||||||
@ -246,14 +246,16 @@ impl EventLoop {
|
|||||||
.build()
|
.build()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let (remote, remote_handle) = alice::run(swap).remote_handle();
|
let (swap, swap_handle) = alice::run(swap).remote_handle();
|
||||||
tokio::spawn(remote);
|
tokio::spawn(swap);
|
||||||
|
|
||||||
let _ = self
|
// For testing purposes the handle is currently sent via a channel so we can
|
||||||
.swap_handle_sender
|
// await it. If a remote handle is dropped, the future of the swap is
|
||||||
.send(remote_handle)
|
// also stopped. If we error upon sending the handle through the channel
|
||||||
.await
|
// we have to call forget to detach the handle from the swap future.
|
||||||
.map_err(|err| warn!("Could not send swap handle over channel: {:?}", err));
|
if let Err(SendError(handle)) = self.swap_handle_sender.send(swap_handle).await {
|
||||||
|
handle.forget();
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user