From 3f417fe5b5c8dcb260521a664c2e134ddda49768 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 17 Nov 2022 16:19:58 +0800 Subject: [PATCH] rename enum option https://github.com/paritytech/substrate/pull/12529#discussion_r1024842194 --- client/cli/src/params/webrtc_certificate_params.rs | 2 +- client/network/src/config.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/cli/src/params/webrtc_certificate_params.rs b/client/cli/src/params/webrtc_certificate_params.rs index 8e309f9bb8867..8fc6ec7846163 100644 --- a/client/cli/src/params/webrtc_certificate_params.rs +++ b/client/cli/src/params/webrtc_certificate_params.rs @@ -51,7 +51,7 @@ impl WebRTCCertificateParams { .clone() .unwrap_or_else(|| net_config_dir.join(WEBRTC_CERTIFICATE_FILENAME)); - Ok(WebRTCConfig::Certificate(Some(cert))) + Ok(WebRTCConfig::File(Some(cert))) } } diff --git a/client/network/src/config.rs b/client/network/src/config.rs index bdc99b4322548..90cbc50f8b17f 100644 --- a/client/network/src/config.rs +++ b/client/network/src/config.rs @@ -465,12 +465,12 @@ where #[derive(Clone, Debug)] pub enum WebRTCConfig { /// A WebRTC certificate. - Certificate(Option), + File(Option), } impl Default for WebRTCConfig { fn default() -> WebRTCConfig { - Self::Certificate(None) + Self::File(None) } } @@ -490,7 +490,7 @@ impl WebRTCConfig { use WebRTCConfig::*; match self { - Certificate(Some(filepath)) => { + File(Some(filepath)) => { let f = std::fs::read(&filepath).or_else(|e| { if e.kind() == io::ErrorKind::NotFound { >::as_ref(&filepath) @@ -517,7 +517,7 @@ impl WebRTCConfig { WebRTCCertificate::from_pem(&pem) .map_err(|e| io::Error::new(io::ErrorKind::Other, e.to_string())) }, - Certificate(None) => generate(), + File(None) => generate(), } } } @@ -566,8 +566,8 @@ mod tests { let tmp = tempdir_with_prefix("x"); std::fs::remove_dir(tmp.path()).unwrap(); // should be recreated let file = tmp.path().join("x").to_path_buf(); - let kp1 = WebRTCConfig::Certificate(Some(file.clone())).into_certificate().unwrap(); - let kp2 = WebRTCConfig::Certificate(Some(file.clone())).into_certificate().unwrap(); + let kp1 = WebRTCConfig::File(Some(file.clone())).into_certificate().unwrap(); + let kp2 = WebRTCConfig::File(Some(file.clone())).into_certificate().unwrap(); assert!(file.is_file() && kp1 == kp2) } }