mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
Avoid pointless conversions, just return the result
This commit is contained in:
committed by
Floris Bruynooghe
parent
4d0a08d858
commit
5c3a8819a4
@@ -198,15 +198,15 @@ fn load_or_generate_self_public_key(
|
||||
self_addr: impl AsRef<str>,
|
||||
) -> Result<SignedPublicKey> {
|
||||
if let Some(key) = Key::from_self_public(context, &self_addr, &context.sql) {
|
||||
return Ok(SignedPublicKey::try_from(key)
|
||||
.map_err(|_| Error::Message("Not a public key".into()))?);
|
||||
return SignedPublicKey::try_from(key)
|
||||
.map_err(|_| Error::Message("Not a public key".into()));
|
||||
}
|
||||
let _guard = context.generating_key_mutex.lock().unwrap();
|
||||
|
||||
// Check again in case the key was generated while we were waiting for the lock.
|
||||
if let Some(key) = Key::from_self_public(context, &self_addr, &context.sql) {
|
||||
return Ok(SignedPublicKey::try_from(key)
|
||||
.map_err(|_| Error::Message("Not a public key".into()))?);
|
||||
return SignedPublicKey::try_from(key)
|
||||
.map_err(|_| Error::Message("Not a public key".into()));
|
||||
}
|
||||
|
||||
let start = std::time::Instant::now();
|
||||
|
||||
Reference in New Issue
Block a user