mirror of
https://github.com/chatmail/core.git
synced 2026-04-20 06:56:29 +03:00
fix: avoid blocking on expensive pgp operations
This commit is contained in:
@@ -220,15 +220,15 @@ impl<'a> Peerstate<'a> {
|
||||
res.public_key = row
|
||||
.get(4)
|
||||
.ok()
|
||||
.and_then(|blob: Vec<u8>| Key::from_slice(&blob, KeyType::Public));
|
||||
.and_then(|blob: Vec<u8>| Key::from_slice(&blob, KeyType::Public).ok());
|
||||
res.gossip_key = row
|
||||
.get(6)
|
||||
.ok()
|
||||
.and_then(|blob: Vec<u8>| Key::from_slice(&blob, KeyType::Public));
|
||||
.and_then(|blob: Vec<u8>| Key::from_slice(&blob, KeyType::Public).ok());
|
||||
res.verified_key = row
|
||||
.get(9)
|
||||
.ok()
|
||||
.and_then(|blob: Vec<u8>| Key::from_slice(&blob, KeyType::Public));
|
||||
.and_then(|blob: Vec<u8>| Key::from_slice(&blob, KeyType::Public).ok());
|
||||
|
||||
Ok(res)
|
||||
})
|
||||
@@ -367,6 +367,15 @@ impl<'a> Peerstate<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn take_key(mut self, min_verified: PeerstateVerifiedStatus) -> Option<Key> {
|
||||
match min_verified {
|
||||
PeerstateVerifiedStatus::BidirectVerified => self.verified_key.take(),
|
||||
PeerstateVerifiedStatus::Unverified => {
|
||||
self.public_key.take().or_else(|| self.gossip_key.take())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn peek_key(&self, min_verified: PeerstateVerifiedStatus) -> Option<&Key> {
|
||||
match min_verified {
|
||||
PeerstateVerifiedStatus::BidirectVerified => self.verified_key.as_ref(),
|
||||
|
||||
Reference in New Issue
Block a user