浏览代码

[fortuna] accept only a secret file as argument (#1204)

* accept file only

* pre commit
Dev Kalra 1 年之前
父节点
当前提交
3e05edba24
共有 5 个文件被更改,包括 4 次插入12 次删除
  1. 1 1
      fortuna/Cargo.lock
  2. 1 1
      fortuna/Cargo.toml
  3. 1 4
      fortuna/src/command/register_provider.rs
  4. 1 5
      fortuna/src/command/run.rs
  5. 0 1
      fortuna/src/config.rs

+ 1 - 1
fortuna/Cargo.lock

@@ -1486,7 +1486,7 @@ dependencies = [
 
 [[package]]
 name = "fortuna"
-version = "3.0.2"
+version = "3.1.0"
 dependencies = [
  "anyhow",
  "axum",

+ 1 - 1
fortuna/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name    = "fortuna"
-version = "3.0.2"
+version = "3.1.0"
 edition = "2021"
 
 [dependencies]

+ 1 - 4
fortuna/src/command/register_provider.rs

@@ -31,10 +31,7 @@ pub async fn register_provider(opts: &RegisterProviderOptions) -> Result<()> {
 
     // Create a new random hash chain.
     let random = rand::random::<[u8; 32]>();
-    let secret = match opts.randomness.load_secret() {
-        Ok(loaded_secret) => loaded_secret,
-        Err(_err) => opts.randomness.secret_file.clone(),
-    };
+    let secret = opts.randomness.load_secret()?;
 
     let commitment_length = opts.randomness.chain_length;
     let mut chain =

+ 1 - 5
fortuna/src/command/run.rs

@@ -47,11 +47,7 @@ pub async fn run(opts: &RunOptions) -> Result<()> {
     struct ApiDoc;
 
     let config = Config::load(&opts.config.config)?;
-    let secret: String;
-    match opts.randomness.load_secret() {
-        Ok(loaded_secret) => secret = loaded_secret,
-        Err(_err) => secret = opts.randomness.secret_file.clone(),
-    }
+    let secret = opts.randomness.load_secret()?;
 
 
     let mut chains = HashMap::new();

+ 0 - 1
fortuna/src/config.rs

@@ -78,7 +78,6 @@ pub struct ConfigOptions {
 pub struct RandomnessOptions {
     /// Path to file containing a secret which is a 64-char hex string.
     /// The secret is used for generating new hash chains
-    /// Or the secret itself. TODO: this will be removed in another PR.
     #[arg(long = "secret")]
     #[arg(env = "FORTUNA_SECRET")]
     pub secret_file: String,