mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Keep around skipped message keys until they're used
This commit is contained in:
parent
1a264595c8
commit
2b3e71cde6
|
@ -109,16 +109,19 @@ public final class SharedSenderKeysImplementation : NSObject {
|
|||
return ratchet
|
||||
} else {
|
||||
var currentKeyIndex = ratchet.keyIndex
|
||||
var result = ratchet
|
||||
var current = ratchet
|
||||
var messageKeys: [String] = []
|
||||
while currentKeyIndex < targetKeyIndex {
|
||||
do {
|
||||
result = try step(result)
|
||||
currentKeyIndex = result.keyIndex
|
||||
current = try step(current)
|
||||
messageKeys += current.messageKeys
|
||||
currentKeyIndex = current.keyIndex
|
||||
} catch {
|
||||
print("[Loki] Couldn't step ratchet due to error: \(error).")
|
||||
throw error
|
||||
}
|
||||
}
|
||||
let result = ClosedGroupRatchet(chainKey: current.chainKey, keyIndex: current.keyIndex, messageKeys: messageKeys) // Includes any skipped message keys
|
||||
Storage.setClosedGroupRatchet(for: groupPublicKey, senderPublicKey: senderPublicKey, ratchet: result, using: transaction)
|
||||
return result
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue