From 5682e715e65f82bfad3c3e6704a0bc9207bf0740 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 5 Mar 2021 10:07:48 +0100 Subject: [PATCH] prevent multiple checks if a new room key is better --- src/matrix/e2ee/megolm/decryption/RoomKey.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/matrix/e2ee/megolm/decryption/RoomKey.js b/src/matrix/e2ee/megolm/decryption/RoomKey.js index 1880961b..dc961627 100644 --- a/src/matrix/e2ee/megolm/decryption/RoomKey.js +++ b/src/matrix/e2ee/megolm/decryption/RoomKey.js @@ -6,9 +6,10 @@ export class BaseRoomKey { this._isBetter = null; } - - async createSessionInfo(olm, pickleKey, txn) { + if (this._isBetter === false) { + return; + } const session = new olm.InboundGroupSession(); try { this._loadSessionKey(session); @@ -32,6 +33,7 @@ export class BaseRoomKey { async _isBetterThanKnown(session, olm, pickleKey, txn) { let isBetter = true; + // TODO: we could potentially have a small speedup here if we looked first in the SessionCache here... const existingSessionEntry = await txn.inboundGroupSessions.get(this.roomId, this.senderKey, this.sessionId); if (existingSessionEntry?.session) { const existingSession = new olm.InboundGroupSession();