Merge pull request #5872 from vector-im/feature/bca/crypto_olm_faster_decrypt
olm try to decrypt with recent session first
This commit is contained in:
commit
cbc29d0699
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 ->
|
olmSessions.getOrPut(deviceKey) { mutableListOf() }.forEach { cached ->
|
||||||
getSafeSessionIdentifier(cached.olmSession)?.let { cachedSessionId ->
|
getSafeSessionIdentifier(cached.olmSession)?.let { cachedSessionId ->
|
||||||
if (!persistedKnownSessions.contains(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) {
|
return doWithRealm(realmConfiguration) {
|
||||||
it.where<OlmSessionEntity>()
|
it.where<OlmSessionEntity>()
|
||||||
.equalTo(OlmSessionEntityFields.DEVICE_KEY, deviceKey)
|
.equalTo(OlmSessionEntityFields.DEVICE_KEY, deviceKey)
|
||||||
|
.sort(OlmSessionEntityFields.LAST_RECEIVED_MESSAGE_TS, Sort.DESCENDING)
|
||||||
.findAll()
|
.findAll()
|
||||||
.mapNotNull { sessionEntity ->
|
.mapNotNull { sessionEntity ->
|
||||||
sessionEntity.sessionId
|
sessionEntity.sessionId
|
||||||
|
Loading…
Reference in New Issue
Block a user