From b06321a40f0279aa1f243b00004f42836bbc66fd Mon Sep 17 00:00:00 2001 From: rishflab Date: Tue, 1 Dec 2020 14:46:53 +1100 Subject: [PATCH] WIP: cleanup --- swap/src/alice/execution.rs | 2 -- swap/src/bob/execution.rs | 9 ++++----- swap/src/bob/swap.rs | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/swap/src/alice/execution.rs b/swap/src/alice/execution.rs index aea07512..afe6d544 100644 --- a/swap/src/alice/execution.rs +++ b/swap/src/alice/execution.rs @@ -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()) diff --git a/swap/src/bob/execution.rs b/swap/src/bob/execution.rs index 86f839c2..abe31815 100644 --- a/swap/src/bob/execution.rs +++ b/swap/src/bob/execution.rs @@ -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( @@ -16,7 +15,7 @@ pub async fn negotiate( addr: Multiaddr, mut rng: R, bitcoin_wallet: Arc, -) -> Result<(SwapAmounts, State2)> +) -> Result 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) } diff --git a/swap/src/bob/swap.rs b/swap/src/bob/swap.rs index 2a3a3a3f..21b97b3d 100644 --- a/swap/src/bob/swap.rs +++ b/swap/src/bob/swap.rs @@ -54,7 +54,7 @@ where peer_id, addr, } => { - let (swap_amounts, state2) = negotiate( + let state2 = negotiate( state0, amounts, &mut swarm,