@@ -60,38 +60,12 @@ impl Session {
6060 & self ,
6161 mut credential : Credential ,
6262 ) -> Result < Arc < Credential > > {
63- let credential_ref = credential
63+ let _credential_ref = credential
6464 . save ( & self . crypto_provider . keystore ( ) )
6565 . await
6666 . map_err ( RecursiveError :: mls_credential ( "saving credential" ) ) ?;
6767
6868 let guard = self . inner . upgradable_read ( ) . await ;
69- let inner = guard. as_ref ( ) . ok_or ( Error :: MlsNotInitialized ) ?;
70-
71- // failfast before loading the cache if we know already that this credential ref can't be added to the identity
72- // set
73- let distinct_result = inner. identities . ensure_distinct (
74- credential_ref. signature_scheme ( ) ,
75- credential_ref. r#type ( ) ,
76- credential_ref. earliest_validity ( ) ,
77- ) ;
78- if let Err ( err) = distinct_result {
79- // first clean up by removing the credential we just saved
80- // otherwise, we'll have nondeterministic results when we load
81- //
82- // TODO this depends for correctness that no two added credentials have the same keypair;
83- // if this happens for a keypair which was removed, we'll remove the (old, used) keypair
84- // and forever after be unable to mls_init on that DB due to a missing keypair for the given credential
85- // this is pointlessly difficult to check right now, but we should do a uniqueness check
86- // after WPB-20844
87- credential
88- . delete ( & self . crypto_provider . keystore ( ) )
89- . await
90- . map_err ( RecursiveError :: mls_credential (
91- "deleting nondistinct credential from keystore" ,
92- ) ) ?;
93- return Err ( err) ;
94- }
9569
9670 // only upgrade to a write guard here in order to minimize the amount of time the unique lock is held
9771 let mut guard = async_lock:: RwLockUpgradableReadGuard :: upgrade ( guard) . await ;
0 commit comments