From ac0b0150e6a33f4213920c036e70f642f666ed8b Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Mon, 21 Jun 2021 11:56:04 +1000 Subject: [PATCH] Upgrade to Rust 1.53 Also fix all clippy lints that came up. --- rust-toolchain.toml | 2 +- swap/src/bin/swap.rs | 24 +++++++++--------------- swap/src/protocol/bob/state.rs | 2 +- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 242a73de..5c4233dd 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.52" +channel = "1.53" components = ["clippy"] targets = ["armv7-unknown-linux-gnueabihf"] diff --git a/swap/src/bin/swap.rs b/swap/src/bin/swap.rs index abf98128..0cb557b7 100644 --- a/swap/src/bin/swap.rs +++ b/swap/src/bin/swap.rs @@ -343,7 +343,7 @@ async fn determine_btc_to_swap( bid_quote: impl Future>, get_new_address: impl Future>, balance: FB, - max_giveable: FMG, + max_giveable_fn: FMG, sync: FS, ) -> Result<(bitcoin::Amount, bitcoin::Amount)> where @@ -363,11 +363,9 @@ where "Received quote: 1 XMR ~ ", ); - let mut current_maximum_giveable = max_giveable().await?; + let mut max_giveable = max_giveable_fn().await?; - let max_giveable = if current_maximum_giveable == bitcoin::Amount::ZERO - || current_maximum_giveable < bid_quote.min_quantity - { + if max_giveable == bitcoin::Amount::ZERO || max_giveable < bid_quote.min_quantity { let deposit_address = get_new_address.await?; let minimum_amount = bid_quote.min_quantity; let maximum_amount = bid_quote.max_quantity; @@ -378,7 +376,7 @@ where info!( %deposit_address, - %current_maximum_giveable, + %max_giveable, %minimum_amount, %maximum_amount, "Please deposit BTC you want to swap to", @@ -387,19 +385,19 @@ where loop { sync().await?; - let new_max_givable = max_giveable().await?; + let new_max_givable = max_giveable_fn().await?; - if new_max_givable != current_maximum_giveable { - current_maximum_giveable = new_max_givable; + if new_max_givable != max_giveable { + max_giveable = new_max_givable; let new_balance = balance().await?; tracing::info!( %new_balance, - %current_maximum_giveable, + %max_giveable, "Received BTC", ); - if current_maximum_giveable >= bid_quote.min_quantity { + if max_giveable >= bid_quote.min_quantity { break; } else { tracing::info!( @@ -412,10 +410,6 @@ where tokio::time::sleep(Duration::from_secs(1)).await; } - - current_maximum_giveable - } else { - current_maximum_giveable }; let balance = balance().await?; diff --git a/swap/src/protocol/bob/state.rs b/swap/src/protocol/bob/state.rs index 758a0f93..94481fe0 100644 --- a/swap/src/protocol/bob/state.rs +++ b/swap/src/protocol/bob/state.rs @@ -157,7 +157,7 @@ impl State0 { let valid = CROSS_CURVE_PROOF_SYSTEM.verify( &msg.dleq_proof_s_a, ( - msg.S_a_bitcoin.clone().into(), + msg.S_a_bitcoin.into(), msg.S_a_monero .point .decompress()