WIP: cleanup

This commit is contained in:
rishflab 2020-12-01 14:46:53 +11:00
parent 47c3ddc6f7
commit b06321a40f
3 changed files with 5 additions and 8 deletions

View File

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

View File

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

View File

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