diff --git a/common/clients/multi-tcp-client/src/connection_manager/mod.rs b/common/clients/multi-tcp-client/src/connection_manager/mod.rs index a695ca05c9..bbd0f8bcd7 100644 --- a/common/clients/multi-tcp-client/src/connection_manager/mod.rs +++ b/common/clients/multi-tcp-client/src/connection_manager/mod.rs @@ -77,7 +77,7 @@ impl<'a> ConnectionManager<'a> { return match conn_writer.write_all(msg).await { // if we failed to write to connection we should reconnect // TODO: is this true? can we fail to write to a connection while it still remains open and valid? - Ok(res) => Ok(res), + Ok(_) => Ok(()), Err(e) => { trace!("Creating connection reconnector!"); self.state = ConnectionState::Reconnecting(ConnectionReconnector::new( diff --git a/common/crypto/src/identity/mod.rs b/common/crypto/src/identity/mod.rs index 192b4911df..9b7a396671 100644 --- a/common/crypto/src/identity/mod.rs +++ b/common/crypto/src/identity/mod.rs @@ -121,8 +121,8 @@ impl MixIdentityPrivateKey { // TODO: this will be implemented differently by using the proper trait impl MixIdentityPrivateKey { - pub fn as_scalar(self) -> Scalar { - let encryption_key = self.0; + pub fn as_scalar(&self) -> Scalar { + let encryption_key = &self.0; encryption_key.0 } } diff --git a/mixnode/src/node/listener.rs b/mixnode/src/node/listener.rs index 7146318ad0..0409a1754d 100644 --- a/mixnode/src/node/listener.rs +++ b/mixnode/src/node/listener.rs @@ -55,7 +55,7 @@ async fn process_socket_connection( // we must be able to handle multiple packets from same connection independently tokio::spawn(process_received_packet( - buf.clone(), + buf, // note: processing_data is relatively cheap (and safe) to clone - // it contains arc to private key and metrics reporter (which is just // a single mpsc unbounded sender) diff --git a/nym-client/src/client/mod.rs b/nym-client/src/client/mod.rs index 437d32e700..dbb975c7bc 100644 --- a/nym-client/src/client/mod.rs +++ b/nym-client/src/client/mod.rs @@ -83,7 +83,7 @@ impl NymClient { .providers() .iter() .find(|provider| provider.pub_key == provider_id) - .expect(format!("Could not find provider with id {:?} - are you sure it is still online? Perhaps try to run `nym-client init` again to obtain a new provider", provider_id).as_ref()) + .unwrap_or_else( || panic!("Could not find provider with id {:?} - are you sure it is still online? Perhaps try to run `nym-client init` again to obtain a new provider", provider_id)) .client_listener } diff --git a/sfw-provider/src/provider/client_handling/listener.rs b/sfw-provider/src/provider/client_handling/listener.rs index f3cee1bf5e..260c947b07 100644 --- a/sfw-provider/src/provider/client_handling/listener.rs +++ b/sfw-provider/src/provider/client_handling/listener.rs @@ -37,7 +37,7 @@ async fn process_request( .map(|c| c.into_tuple()) .unzip(); let response_bytes = PullResponse::new(messages).to_bytes(); - if let Ok(_) = socket.write_all(&response_bytes).await { + if socket.write_all(&response_bytes).await.is_ok() { // only delete stored messages if we managed to actually send the response if let Err(e) = request_processor.delete_sent_messages(paths).await { error!("Somehow failed to delete stored messages! - {:?}", e); diff --git a/sfw-provider/src/provider/client_handling/request_processing.rs b/sfw-provider/src/provider/client_handling/request_processing.rs index 6e7a36bb08..57707c1b0d 100644 --- a/sfw-provider/src/provider/client_handling/request_processing.rs +++ b/sfw-provider/src/provider/client_handling/request_processing.rs @@ -85,27 +85,26 @@ impl RequestProcessor { ); let auth_token = self.generate_new_auth_token(req.destination_address.clone()); - if let Some(_) = self + if self .client_ledger .insert_token(auth_token.clone(), req.destination_address.clone()) .await + .is_some() { info!( "Client {:?} was already registered before!", req.destination_address.to_base58_string() ) - } else { - if let Err(e) = self - .client_storage - .create_storage_dir(req.destination_address.clone()) - .await - { - error!("We failed to create inbox directory for the client -{:?}\nReverting issued token...", e); - // we must revert our changes if this operation failed - self.client_ledger - .remove_token(&req.destination_address) - .await; - } + } else if let Err(e) = self + .client_storage + .create_storage_dir(req.destination_address.clone()) + .await + { + error!("We failed to create inbox directory for the client -{:?}\nReverting issued token...", e); + // we must revert our changes if this operation failed + self.client_ledger + .remove_token(&req.destination_address) + .await; } Ok(ClientProcessingResult::RegisterResponse(auth_token)) diff --git a/sfw-provider/src/provider/mix_handling/listener.rs b/sfw-provider/src/provider/mix_handling/listener.rs index 00a6b97062..70a37c7841 100644 --- a/sfw-provider/src/provider/mix_handling/listener.rs +++ b/sfw-provider/src/provider/mix_handling/listener.rs @@ -42,10 +42,7 @@ async fn process_socket_connection( } // we must be able to handle multiple packets from same connection independently - tokio::spawn(process_received_packet( - buf.clone(), - packet_processor.clone(), - )) + tokio::spawn(process_received_packet(buf, packet_processor.clone())) } Err(e) => { warn!(