From b24a90ff4e2c4f2836fcbadc28141f29d5c4a132 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Sun, 22 Sep 2024 16:39:14 -0600 Subject: [PATCH] minor readability improvements --- README.md | 2 +- src/rpcserver.rs | 2 +- src/utils.rs | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 932f78f..750350c 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ An initial draft of a workable protocol for "receive tokens in exchange for prov # Caveat -**Everything here is completely experimental and not safe in any way** (not helped by the fact I am a neophyte in Rust!). Importantly, even the underlying Curve Trees code was *only* written as a benchmarking tool, and therefore even that is not safe to use in anything remotely resembling a production environment. +**Everything here is completely experimental and not safe in any way**. Importantly, even the underlying Curve Trees code was *only* written as a benchmarking tool, and therefore even that is not safe to use in anything remotely resembling a production environment. If you choose to play around with this stuff for Bitcoin projects I suggest using signet for now. diff --git a/src/rpcserver.rs b/src/rpcserver.rs index 38c68b3..577de4f 100644 --- a/src/rpcserver.rs +++ b/src/rpcserver.rs @@ -46,7 +46,7 @@ pub async fn do_serve(autctcfg: AutctConfig) -> Result<(), Box>{ convert_keys::(fl.to_string(), - autctcfg.generators_length_log_2.unwrap()).unwrap(); + autctcfg.generators_length_log_2.unwrap())?; let leaf_commitments = get_leaf_commitments( &(fl.to_string() + ".p")); diff --git a/src/utils.rs b/src/utils.rs index e8cf6fa..1cccfb1 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -99,8 +99,8 @@ pub fn read_file_string(filepath: &str) -> Result> { Ok(resp.trim_end().to_string()) } -pub fn write_file_string(filepath: &str, mut buf: Vec) -> () { - fs::write(filepath, &mut buf).expect("Failed to write to file"); +pub fn write_file_string(filepath: &str, buf: Vec) -> () { + fs::write(filepath, buf).expect("Failed to write to file"); } pub fn write_file_string2(loc: PathBuf, mut buf: Vec) ->Result<(), std::io::Error> { @@ -225,12 +225,13 @@ pub fn get_pubkey_leaves_hex Vec>{ // TODO return errors for failed reading let filestr:String = read_file_string(pubkey_file_path) - .expect("my failure message"); + .expect("Failed to read pubkey file"); + let hex_keys_vec = filestr.split_whitespace().collect::>(); if pubkey_file_path.ends_with(".aks"){ get_correct_pubkeys_from_bip340_hex_list(hex_keys_vec).unwrap() } - else { + else { // current convention is ".pks", but not enforced for now get_correct_pubkeys_from_ark_hex_list::(hex_keys_vec).unwrap() } }