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,