diff options
Diffstat (limited to 'src/rpc')
-rw-r--r-- | src/rpc/consul.rs | 6 | ||||
-rw-r--r-- | src/rpc/kubernetes.rs | 6 | ||||
-rw-r--r-- | src/rpc/rpc_helper.rs | 3 |
3 files changed, 5 insertions, 10 deletions
diff --git a/src/rpc/consul.rs b/src/rpc/consul.rs index e70288dd..15acbcef 100644 --- a/src/rpc/consul.rs +++ b/src/rpc/consul.rs @@ -51,10 +51,8 @@ pub async fn get_consul_nodes( let pubkey = ent .node_meta .get("pubkey") - .map(|k| hex::decode(&k).ok()) - .flatten() - .map(|k| NodeID::from_slice(&k[..])) - .flatten(); + .and_then(|k| hex::decode(&k).ok()) + .and_then(|k| NodeID::from_slice(&k[..])); if let (Some(ip), Some(pubkey)) = (ip, pubkey) { ret.push((pubkey, SocketAddr::new(ip, ent.service_port))); } else { diff --git a/src/rpc/kubernetes.rs b/src/rpc/kubernetes.rs index 8c0d6cdf..272d9162 100644 --- a/src/rpc/kubernetes.rs +++ b/src/rpc/kubernetes.rs @@ -63,10 +63,8 @@ pub async fn get_kubernetes_nodes( let pubkey = &node .metadata .name - .map(|k| hex::decode(&k).ok()) - .flatten() - .map(|k| NodeID::from_slice(&k[..])) - .flatten(); + .and_then(|k| hex::decode(&k).ok()) + .and_then(|k| NodeID::from_slice(&k[..])); if let Some(pubkey) = pubkey { ret.push((*pubkey, SocketAddr::new(node.spec.address, node.spec.port))) diff --git a/src/rpc/rpc_helper.rs b/src/rpc/rpc_helper.rs index 1b351024..34717d3b 100644 --- a/src/rpc/rpc_helper.rs +++ b/src/rpc/rpc_helper.rs @@ -322,8 +322,7 @@ impl RpcHelper { let peer_avg_ping = peer_list .iter() .find(|x| x.id.as_ref() == to.as_slice()) - .map(|pi| pi.avg_ping) - .flatten() + .and_then(|pi| pi.avg_ping) .unwrap_or_else(|| Duration::from_secs(1)); ( to != self.0.our_node_id, |