diff --git a/swap/src/api.rs b/swap/src/api.rs index 9f38fbce..36bc9faa 100644 --- a/swap/src/api.rs +++ b/swap/src/api.rs @@ -70,7 +70,7 @@ impl SwapLock { } pub async fn get_current_swap_id(&self) -> Option { - let current_swap = self.current_swap.read().await.clone(); + let current_swap = *self.current_swap.read().await; current_swap } @@ -110,7 +110,7 @@ impl SwapLock { if let Some(swap_id) = current_swap.as_ref() { tracing::debug!(swap_id = %swap_id, "Releasing swap lock"); - let prev_swap_id = swap_id.clone(); + let prev_swap_id = *swap_id; *current_swap = None; drop(current_swap); Ok(prev_swap_id) diff --git a/swap/src/api/request.rs b/swap/src/api/request.rs index 9344d2a4..53a6090f 100644 --- a/swap/src/api/request.rs +++ b/swap/src/api/request.rs @@ -151,7 +151,7 @@ impl Method { } }; if let Some(log_reference_id) = log_reference_id { - span.record("log_reference_id", &log_reference_id.as_str()); + span.record("log_reference_id", log_reference_id.as_str()); } span } @@ -236,7 +236,7 @@ impl Request { let tx_lock_id = state2.tx_lock.txid(); let btc_refund_address = state2.refund_address.to_string(); - return Some(( + Some(( xmr_amount, btc_amount, tx_lock_id, @@ -245,7 +245,7 @@ impl Request { btc_refund_address, state2.cancel_timelock, state2.punish_timelock, - )); + )) } else { None } @@ -307,7 +307,7 @@ impl Request { biased; _ = context.swap_lock.listen_for_swap_force_suspension() => { tracing::debug!("Shutdown signal received, exiting"); - () + }, _ = async { let seed = context.config.seed.as_ref().context("Could not get seed")?; @@ -421,7 +421,7 @@ impl Request { tracing::debug!(%swap_id, "Swap completed"); Ok(()) } => { - () + } }; context @@ -517,11 +517,11 @@ impl Request { }; Ok::<(), anyhow::Error>(()) } => { - () + }, _ = context.swap_lock.listen_for_swap_force_suspension() => { tracing::debug!("Shutdown signal received, exiting"); - () + } } context @@ -728,11 +728,11 @@ impl Request { tracing::info!(address=%address, spend_key=%spend_key, view_key=%view_key, "Monero recovery information"); - return Ok(json!({ + Ok(json!({ "address": address, "spend_key": spend_key.to_string(), "view_key": view_key.to_string(), - })); + })) } else { bail!( "Cannot print monero recovery information in state {}, only possible for BtcRedeemed", @@ -750,7 +750,7 @@ impl Request { let method_span = self .cmd .get_tracing_span(self.log_reference.clone()) - .clone(); + ; self.handle_cmd(context).instrument(method_span).await } diff --git a/swap/src/bitcoin.rs b/swap/src/bitcoin.rs index 92c898a7..556d8453 100644 --- a/swap/src/bitcoin.rs +++ b/swap/src/bitcoin.rs @@ -301,7 +301,7 @@ pub mod bitcoin_address { } else { bitcoin::Network::Bitcoin }; - return validate(address, expected_network); + validate(address, expected_network) } } diff --git a/swap/src/bitcoin/wallet.rs b/swap/src/bitcoin/wallet.rs index 94b49d0d..5617d381 100644 --- a/swap/src/bitcoin/wallet.rs +++ b/swap/src/bitcoin/wallet.rs @@ -1008,7 +1008,7 @@ mod tests { fn given_depth_0_should_meet_confirmation_target_one() { let script = ScriptStatus::Confirmed(Confirmed { depth: 0 }); - let confirmed = script.is_confirmed_with(1 as u32); + let confirmed = script.is_confirmed_with(1_u32); assert!(confirmed) } @@ -1017,7 +1017,7 @@ mod tests { fn given_confirmations_1_should_meet_confirmation_target_one() { let script = ScriptStatus::from_confirmations(1); - let confirmed = script.is_confirmed_with(1 as u32); + let confirmed = script.is_confirmed_with(1_u32); assert!(confirmed) } @@ -1036,7 +1036,7 @@ mod tests { fn given_depth_0_should_return_0_blocks_left_until_1() { let script = ScriptStatus::Confirmed(Confirmed { depth: 0 }); - let blocks_left = script.blocks_left_until(1 as u32); + let blocks_left = script.blocks_left_until(1_u32); assert_eq!(blocks_left, 0) } @@ -1045,7 +1045,7 @@ mod tests { fn given_depth_1_should_return_0_blocks_left_until_1() { let script = ScriptStatus::Confirmed(Confirmed { depth: 1 }); - let blocks_left = script.blocks_left_until(1 as u32); + let blocks_left = script.blocks_left_until(1_u32); assert_eq!(blocks_left, 0) } @@ -1054,7 +1054,7 @@ mod tests { fn given_depth_0_should_return_1_blocks_left_until_2() { let script = ScriptStatus::Confirmed(Confirmed { depth: 0 }); - let blocks_left = script.blocks_left_until(2 as u32); + let blocks_left = script.blocks_left_until(2_u32); assert_eq!(blocks_left, 1) } diff --git a/swap/src/rpc/methods.rs b/swap/src/rpc/methods.rs index f0dad7b3..6cdada40 100644 --- a/swap/src/rpc/methods.rs +++ b/swap/src/rpc/methods.rs @@ -233,7 +233,7 @@ async fn execute_request( .ok() .and_then(|params_parsed| params_parsed.get("log_reference_id").cloned()); - let request = Request::with_id(cmd, reference_id.map(|s| s.clone())); + let request = Request::with_id(cmd, reference_id); request .call(Arc::clone(context)) .await diff --git a/swap/tests/harness/mod.rs b/swap/tests/harness/mod.rs index b42b37ee..7d7209ef 100644 --- a/swap/tests/harness/mod.rs +++ b/swap/tests/harness/mod.rs @@ -416,7 +416,7 @@ impl BobParams { pub fn get_concentenated_alice_address(&self) -> String { format!( "{}/p2p/{}", - self.alice_address.clone().to_string(), + self.alice_address.clone(), self.alice_peer_id.clone().to_base58() ) }