mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-11-19 09:25:33 +00:00
Remove mspc channel from new executor
This commit is contained in:
parent
2db9ebd28b
commit
d8218a7bea
@ -19,9 +19,6 @@ pub async fn negotiate<R>(
|
|||||||
where
|
where
|
||||||
R: RngCore + CryptoRng + Send,
|
R: RngCore + CryptoRng + Send,
|
||||||
{
|
{
|
||||||
let (mut cmd_tx, _cmd_rx) = mpsc::channel(1);
|
|
||||||
let (_rsp_tx, mut rsp_rx) = mpsc::channel(1);
|
|
||||||
|
|
||||||
// todo: dial the swarm outside
|
// todo: dial the swarm outside
|
||||||
// libp2p::Swarm::dial_addr(&mut swarm, addr)?;
|
// libp2p::Swarm::dial_addr(&mut swarm, addr)?;
|
||||||
let alice = match swarm.next().await {
|
let alice = match swarm.next().await {
|
||||||
@ -31,22 +28,12 @@ where
|
|||||||
|
|
||||||
swarm.request_amounts(alice.clone(), amounts.btc.as_sat());
|
swarm.request_amounts(alice.clone(), amounts.btc.as_sat());
|
||||||
|
|
||||||
// todo: remove/refactor mspc channel
|
// todo: see if we can remove
|
||||||
let (btc, xmr) = match swarm.next().await {
|
let (btc, xmr) = match swarm.next().await {
|
||||||
OutEvent::Amounts(amounts) => {
|
OutEvent::Amounts(amounts) => (amounts.btc, amounts.xmr),
|
||||||
let cmd = Cmd::VerifyAmounts(amounts);
|
|
||||||
cmd_tx.try_send(cmd)?;
|
|
||||||
let response = rsp_rx.next().await;
|
|
||||||
if response == Some(Rsp::Abort) {
|
|
||||||
panic!("abort response");
|
|
||||||
}
|
|
||||||
(amounts.btc, amounts.xmr)
|
|
||||||
}
|
|
||||||
other => panic!("unexpected event: {:?}", other),
|
other => panic!("unexpected event: {:?}", other),
|
||||||
};
|
};
|
||||||
|
|
||||||
let refund_address = bitcoin_wallet.as_ref().new_address().await?;
|
|
||||||
|
|
||||||
swarm.send_message0(alice.clone(), state0.next_message(&mut rng));
|
swarm.send_message0(alice.clone(), state0.next_message(&mut rng));
|
||||||
let state1 = match swarm.next().await {
|
let state1 = match swarm.next().await {
|
||||||
OutEvent::Message0(msg) => state0.receive(bitcoin_wallet.as_ref(), msg).await?,
|
OutEvent::Message0(msg) => state0.receive(bitcoin_wallet.as_ref(), msg).await?,
|
||||||
|
Loading…
Reference in New Issue
Block a user