File tree 1 file changed +4
-6
lines changed
crates/matrix-sdk-crypto/src/store 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,8 @@ pub struct MemoryStore {
103
103
dehydrated_device_pickle_key : RwLock < Option < DehydratedDeviceKey > > ,
104
104
next_batch_token : RwLock < Option < String > > ,
105
105
room_settings : StdRwLock < HashMap < OwnedRoomId , RoomSettings > > ,
106
- room_key_bundles : StdRwLock < HashMap < OwnedRoomId , Vec < StoredRoomKeyBundleData > > > ,
106
+ room_key_bundles :
107
+ StdRwLock < HashMap < OwnedRoomId , HashMap < OwnedUserId , StoredRoomKeyBundleData > > > ,
107
108
108
109
save_changes_lock : Arc < Mutex < ( ) > > ,
109
110
}
@@ -328,7 +329,7 @@ impl CryptoStore for MemoryStore {
328
329
room_key_bundles
329
330
. entry ( bundle. bundle_data . room_id . clone ( ) )
330
331
. or_default ( )
331
- . push ( bundle) ;
332
+ . insert ( bundle . sender_user . clone ( ) , bundle) ;
332
333
}
333
334
}
334
335
@@ -710,10 +711,7 @@ impl CryptoStore for MemoryStore {
710
711
) -> Result < Option < StoredRoomKeyBundleData > > {
711
712
let guard = self . room_key_bundles . read ( ) ;
712
713
713
- let result = guard. get ( room_id) . and_then ( |bundles| {
714
- // Find the most recently-added entry from this user
715
- bundles. iter ( ) . rfind ( |b| b. sender_user == user_id) . cloned ( )
716
- } ) ;
714
+ let result = guard. get ( room_id) . and_then ( |bundles| bundles. get ( user_id) . cloned ( ) ) ;
717
715
718
716
Ok ( result)
719
717
}
You can’t perform that action at this time.
0 commit comments