WIP: cleanup

pull/41/head
rishflab 4 years ago
parent 47c3ddc6f7
commit b06321a40f

@ -97,8 +97,6 @@ pub async fn negotiate(
other => bail!("Unexpected event received: {:?}", other), other => bail!("Unexpected event received: {:?}", other),
}; };
let SwapAmounts { btc, xmr } = amounts;
let state1 = state0.receive(message0)?; let state1 = state0.receive(message0)?;
let event = timeout(*BOB_TIME_TO_ACT, swarm.next()) let event = timeout(*BOB_TIME_TO_ACT, swarm.next())

@ -1,12 +1,11 @@
use crate::{ use crate::{
bob::{OutEvent, Swarm}, bob::{OutEvent, Swarm},
Cmd, Rsp, SwapAmounts, SwapAmounts,
}; };
use anyhow::Result; use anyhow::Result;
use libp2p::core::Multiaddr; use libp2p::core::Multiaddr;
use rand::{CryptoRng, RngCore}; use rand::{CryptoRng, RngCore};
use std::sync::Arc; use std::sync::Arc;
use tokio::{stream::StreamExt, sync::mpsc};
use xmr_btc::bob::State2; use xmr_btc::bob::State2;
pub async fn negotiate<R>( pub async fn negotiate<R>(
@ -16,7 +15,7 @@ pub async fn negotiate<R>(
addr: Multiaddr, addr: Multiaddr,
mut rng: R, mut rng: R,
bitcoin_wallet: Arc<crate::bitcoin::Wallet>, bitcoin_wallet: Arc<crate::bitcoin::Wallet>,
) -> Result<(SwapAmounts, State2)> ) -> Result<State2>
where where
R: RngCore + CryptoRng + Send, R: RngCore + CryptoRng + Send,
{ {
@ -30,7 +29,7 @@ where
swarm.request_amounts(alice.clone(), amounts.btc.as_sat()); swarm.request_amounts(alice.clone(), amounts.btc.as_sat());
// todo: see if we can remove // todo: see if we can remove
let (btc, xmr) = match swarm.next().await { let (_btc, _xmr) = match swarm.next().await {
OutEvent::Amounts(amounts) => (amounts.btc, amounts.xmr), OutEvent::Amounts(amounts) => (amounts.btc, amounts.xmr),
other => panic!("unexpected event: {:?}", other), other => panic!("unexpected event: {:?}", other),
}; };
@ -49,5 +48,5 @@ where
swarm.send_message2(alice.clone(), state2.next_message()); swarm.send_message2(alice.clone(), state2.next_message());
Ok((amounts, state2)) Ok(state2)
} }

@ -54,7 +54,7 @@ where
peer_id, peer_id,
addr, addr,
} => { } => {
let (swap_amounts, state2) = negotiate( let state2 = negotiate(
state0, state0,
amounts, amounts,
&mut swarm, &mut swarm,

Loading…
Cancel
Save