Use if let to avoid unwrap() of peerstate

This commit is contained in:
Alexander Krotov
2020-01-11 15:39:44 +03:00
committed by holger krekel
parent a82f2a5df3
commit 742f603b3b

View File

@@ -1374,12 +1374,11 @@ fn check_verified_properties(
context.is_self_addr(&to_addr)
);
let mut is_verified = _is_verified != 0;
let mut peerstate = Peerstate::from_addr(context, &context.sql, &to_addr);
let peerstate = Peerstate::from_addr(context, &context.sql, &to_addr);
// mark gossiped keys (if any) as verified
if mimeparser.gossipped_addr.contains(&to_addr) && peerstate.is_some() {
let peerstate = peerstate.as_mut().unwrap();
if mimeparser.gossipped_addr.contains(&to_addr) {
if let Some(mut peerstate) = peerstate {
// if we're here, we know the gossip key is verified:
// - use the gossip-key as verified-key if there is no verified-key
// - OR if the verified-key does not match public-key or gossip-key
@@ -1402,6 +1401,7 @@ fn check_verified_properties(
}
}
}
}
if !is_verified {
bail!(
"{} is not a member of this verified group",