From b8001b78b4aa60510c9ce2ddf92b1b24a68edbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Mon, 13 Sep 2021 10:18:23 +0200 Subject: [PATCH] fix(crypto): Fix some clippy warnings --- matrix_sdk_crypto/src/identities/device.rs | 3 +-- matrix_sdk_crypto/src/store/mod.rs | 1 - matrix_sdk_crypto/src/store/sled.rs | 3 --- matrix_sdk_crypto/src/verification/qrcode.rs | 15 ++++----------- matrix_sdk_crypto/src/verification/requests.rs | 3 +-- .../src/verification/sas/sas_state.rs | 2 +- 6 files changed, 7 insertions(+), 20 deletions(-) diff --git a/matrix_sdk_crypto/src/identities/device.rs b/matrix_sdk_crypto/src/identities/device.rs index 37e29849..a80d2c38 100644 --- a/matrix_sdk_crypto/src/identities/device.rs +++ b/matrix_sdk_crypto/src/identities/device.rs @@ -42,7 +42,7 @@ use super::{atomic_bool_deserializer, atomic_bool_serializer}; use crate::{ error::{EventError, OlmError, OlmResult, SignatureError}, identities::{ReadOnlyOwnUserIdentity, ReadOnlyUserIdentities}, - olm::{InboundGroupSession, PrivateCrossSigningIdentity, Session, Utility}, + olm::{InboundGroupSession, Session, Utility}, store::{Changes, CryptoStore, DeviceChanges, Result as StoreResult}, verification::VerificationMachine, OutgoingVerificationRequest, Sas, ToDeviceRequest, VerificationRequest, @@ -296,7 +296,6 @@ impl Device { #[derive(Debug)] pub struct UserDevices { pub(crate) inner: HashMap, - pub(crate) private_identity: Arc>, pub(crate) verification_machine: VerificationMachine, pub(crate) own_identity: Option, pub(crate) device_owner_identity: Option, diff --git a/matrix_sdk_crypto/src/store/mod.rs b/matrix_sdk_crypto/src/store/mod.rs index 3984180f..c8b1976b 100644 --- a/matrix_sdk_crypto/src/store/mod.rs +++ b/matrix_sdk_crypto/src/store/mod.rs @@ -309,7 +309,6 @@ impl Store { Ok(UserDevices { inner: devices, - private_identity: self.identity.clone(), verification_machine: self.verification_machine.clone(), own_identity, device_owner_identity, diff --git a/matrix_sdk_crypto/src/store/sled.rs b/matrix_sdk_crypto/src/store/sled.rs index e2838c62..e25ba6d0 100644 --- a/matrix_sdk_crypto/src/store/sled.rs +++ b/matrix_sdk_crypto/src/store/sled.rs @@ -164,7 +164,6 @@ pub struct SledStore { identities: Tree, tracked_users: Tree, - users_for_key_query: Tree, } impl std::fmt::Debug for SledStore { @@ -246,7 +245,6 @@ impl SledStore { let outbound_group_sessions = db.open_tree("outbound_group_sessions")?; let tracked_users = db.open_tree("tracked_users")?; - let users_for_key_query = db.open_tree("users_for_key_query")?; let olm_hashes = db.open_tree("olm_hashes")?; let devices = db.open_tree("devices")?; @@ -283,7 +281,6 @@ impl SledStore { secret_requests_by_info, devices, tracked_users, - users_for_key_query, olm_hashes, identities, }) diff --git a/matrix_sdk_crypto/src/verification/qrcode.rs b/matrix_sdk_crypto/src/verification/qrcode.rs index cdc89bab..918c5670 100644 --- a/matrix_sdk_crypto/src/verification/qrcode.rs +++ b/matrix_sdk_crypto/src/verification/qrcode.rs @@ -80,7 +80,6 @@ pub enum ScanError { #[derive(Clone)] pub struct QrVerification { flow_id: FlowId, - store: VerificationStore, inner: Arc, state: Arc>, identities: IdentitiesBeingVerified, @@ -429,7 +428,6 @@ impl QrVerification { } pub(crate) fn new_self( - store: VerificationStore, flow_id: FlowId, own_master_key: String, other_device_key: String, @@ -447,7 +445,7 @@ impl QrVerification { ) .into(); - Self::new_helper(store, flow_id, inner, identities, we_started, request_handle) + Self::new_helper(flow_id, inner, identities, we_started, request_handle) } pub(crate) fn new_self_no_master( @@ -468,11 +466,10 @@ impl QrVerification { ) .into(); - Self::new_helper(store, flow_id, inner, identities, we_started, request_handle) + Self::new_helper(flow_id, inner, identities, we_started, request_handle) } pub(crate) fn new_cross( - store: VerificationStore, flow_id: FlowId, own_master_key: String, other_master_key: String, @@ -491,7 +488,7 @@ impl QrVerification { let inner: QrVerificationData = VerificationData::new(event_id, own_master_key, other_master_key, secret).into(); - Self::new_helper(store, flow_id, inner, identities, we_started, request_handle) + Self::new_helper(flow_id, inner, identities, we_started, request_handle) } #[allow(clippy::too_many_arguments)] @@ -585,7 +582,6 @@ impl QrVerification { let own_device_id = store.account.device_id().to_owned(); Ok(Self { - store, flow_id, inner: qr_code.into(), state: Mutex::new(InnerState::Reciprocated(QrState { @@ -599,7 +595,6 @@ impl QrVerification { } fn new_helper( - store: VerificationStore, flow_id: FlowId, inner: QrVerificationData, identities: IdentitiesBeingVerified, @@ -609,7 +604,6 @@ impl QrVerification { let secret = inner.secret().to_owned(); Self { - store, flow_id, inner: inner.into(), state: Mutex::new(InnerState::Created(QrState { state: Created { secret } })).into(), @@ -851,7 +845,6 @@ mod test { assert_eq!(verification.inner.second_key(), &master_key); let verification = QrVerification::new_self( - store.clone(), flow_id, master_key.clone(), device_key.clone(), @@ -870,7 +863,6 @@ mod test { let flow_id = FlowId::InRoom(room_id!("!test:example"), event_id!("$EVENTID")); let verification = QrVerification::new_cross( - store.clone(), flow_id, master_key.clone(), bob_master_key.clone(), @@ -972,6 +964,7 @@ mod test { assert!(bob_verification.is_done()); let identity = alice_verification + .identities .store .get_user_identity(alice_account.user_id()) .await diff --git a/matrix_sdk_crypto/src/verification/requests.rs b/matrix_sdk_crypto/src/verification/requests.rs index b300ea06..cdf9f5f9 100644 --- a/matrix_sdk_crypto/src/verification/requests.rs +++ b/matrix_sdk_crypto/src/verification/requests.rs @@ -999,7 +999,6 @@ impl RequestState { identites.other_device().get_key(DeviceKeyAlgorithm::Ed25519) { Some(QrVerification::new_self( - self.store.clone(), self.flow_id.as_ref().to_owned(), master_key.to_owned(), device_key.to_owned(), @@ -1048,7 +1047,6 @@ impl RequestState { .and_then(|m| m.get_first_key().map(|m| m.to_owned())) { Some(QrVerification::new_cross( - self.store.clone(), self.flow_id.as_ref().to_owned(), own_master, other_master.to_owned(), @@ -1251,6 +1249,7 @@ impl RequestState { #[derive(Clone, Debug)] struct Passive { /// The device id of the device that responded to the verification request. + #[allow(dead_code)] pub other_device_id: DeviceIdBox, } diff --git a/matrix_sdk_crypto/src/verification/sas/sas_state.rs b/matrix_sdk_crypto/src/verification/sas/sas_state.rs index 78bfd541..8b449729 100644 --- a/matrix_sdk_crypto/src/verification/sas/sas_state.rs +++ b/matrix_sdk_crypto/src/verification/sas/sas_state.rs @@ -665,7 +665,7 @@ impl SasState { last_event_time: Instant::now().into(), started_from_request: self.started_from_request, state: Arc::new(KeyReceived { - we_started: false, + we_started: self.state.we_started, their_pubkey, accepted_protocols: self.state.accepted_protocols.clone(), }),