mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-26 09:33:14 +01:00
olm try to decrypt with recent session first
This commit is contained in:
parent
cd52df5d2e
commit
50a4d2ba0a
1
changelog.d/5872.misc
Normal file
1
changelog.d/5872.misc
Normal file
@ -0,0 +1 @@
|
||||
Faster Olm decrypt when there is a lot of existing sessions
|
@ -66,7 +66,8 @@ internal class OlmSessionStore @Inject constructor(private val store: IMXCryptoS
|
||||
olmSessions.getOrPut(deviceKey) { mutableListOf() }.forEach { cached ->
|
||||
getSafeSessionIdentifier(cached.olmSession)?.let { cachedSessionId ->
|
||||
if (!persistedKnownSessions.contains(cachedSessionId)) {
|
||||
persistedKnownSessions.add(cachedSessionId)
|
||||
// as it's in cache put in on top
|
||||
persistedKnownSessions.add(0, cachedSessionId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -715,6 +715,7 @@ internal class RealmCryptoStore @Inject constructor(
|
||||
return doWithRealm(realmConfiguration) {
|
||||
it.where<OlmSessionEntity>()
|
||||
.equalTo(OlmSessionEntityFields.DEVICE_KEY, deviceKey)
|
||||
.sort(OlmSessionEntityFields.LAST_RECEIVED_MESSAGE_TS, Sort.DESCENDING)
|
||||
.findAll()
|
||||
.mapNotNull { sessionEntity ->
|
||||
sessionEntity.sessionId
|
||||
|
Loading…
Reference in New Issue
Block a user