Skip to content

Commit 5965643

Browse files
author
eigmax
committed
chore: code polishing
1 parent 202e2ac commit 5965643

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

sdk/src/network/prover.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ pub struct NetworkProver {
3333

3434
impl NetworkProver {
3535
pub async fn new(client_config: &ClientCfg) -> anyhow::Result<NetworkProver> {
36-
let ca_cert_path = client_config.ca_cert_path.to_owned().expect("CA_CERT_PATH must be set");
37-
let cert_path = client_config.cert_path.to_owned().expect("CERT_PATH must be set");
38-
let key_path = client_config.key_path.to_owned().expect("KEY_PATH must be set");
39-
let ssl_config = if ca_cert_path.is_empty() {
36+
let ssl_config = if client_config.ca_cert_path.as_ref().is_none() {
4037
None
4138
} else {
42-
let (ca_cert, identity) =
43-
get_cert_and_identity(ca_cert_path, cert_path, key_path).await?;
39+
let (ca_cert, identity) = get_cert_and_identity(
40+
client_config.ca_cert_path.as_ref().expect("CA_CERT_PATH not set"),
41+
client_config.cert_path.as_ref().expect("CERT_PATH not set"),
42+
client_config.key_path.as_ref().expect("KEY_PATH not set"),
43+
)
44+
.await?;
4445
Some(Config { ca_cert, identity })
4546
};
4647
let endpoint_para = client_config.endpoint.to_owned().expect("ENDPOINT must be set");
@@ -228,13 +229,13 @@ impl Prover for NetworkProver {
228229
}
229230

230231
async fn get_cert_and_identity(
231-
ca_cert_path: String,
232-
cert_path: String,
233-
key_path: String,
232+
ca_cert_path: &str,
233+
cert_path: &str,
234+
key_path: &str,
234235
) -> anyhow::Result<(Option<Certificate>, Option<Identity>)> {
235-
let ca_cert_path = Path::new(&ca_cert_path);
236-
let cert_path = Path::new(&cert_path);
237-
let key_path = Path::new(&key_path);
236+
let ca_cert_path = Path::new(ca_cert_path);
237+
let cert_path = Path::new(cert_path);
238+
let key_path = Path::new(key_path);
238239
// if !ca_cert_path.is_file() || !cert_path.is_file() || !key_path.is_file() {
239240
// bail!("both ca_cert_path, cert_path and key_path should be valid file")
240241
// }

sdk/src/prover.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ impl ClientCfg {
3232
let snark_setup =
3333
env::var("SNARK_SETUP").ok().and_then(|seg| seg.parse::<bool>().ok()).unwrap_or(false);
3434

35-
let guest_input = match env::var("ARGS") {
36-
Ok(input) => Some(input),
37-
_ => None,
38-
};
35+
let guest_input = env::var("ARGS").ok();
3936
let elf_path = env::var("ELF_PATH").expect("ELF not found");
4037
println!("{}", elf_path);
4138
let proof_results_path =

0 commit comments

Comments
 (0)