From 9f0fbcccf650038a96b3dd6cd938e8a69f3df9f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Mon, 3 Aug 2020 16:18:35 +0200 Subject: [PATCH] crypto: Remove verification objects that are done or canceled. --- matrix_sdk_crypto/src/machine.rs | 2 ++ matrix_sdk_crypto/src/verification/machine.rs | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/matrix_sdk_crypto/src/machine.rs b/matrix_sdk_crypto/src/machine.rs index a5f5d36c..d6765b1b 100644 --- a/matrix_sdk_crypto/src/machine.rs +++ b/matrix_sdk_crypto/src/machine.rs @@ -1094,6 +1094,8 @@ impl OlmMachine { /// * `response` - The sync latest sync response. #[instrument(skip(response))] pub async fn receive_sync_response(&mut self, response: &mut SyncResponse) { + self.verification_machine.garbage_collect(); + let one_time_key_count = response .device_one_time_keys_count .get(&keys::KeyAlgorithm::SignedCurve25519); diff --git a/matrix_sdk_crypto/src/verification/machine.rs b/matrix_sdk_crypto/src/verification/machine.rs index 579e0b2a..9af9a16b 100644 --- a/matrix_sdk_crypto/src/verification/machine.rs +++ b/matrix_sdk_crypto/src/verification/machine.rs @@ -81,6 +81,11 @@ impl VerificationMachine { .collect() } + pub fn garbage_collect(&self) { + self.verifications + .retain(|_, s| !(s.is_canceled() || s.is_done())); + } + pub async fn receive_event( &self, event: &mut AnyToDeviceEvent,