-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify public param config with config.rs, spin out CLI config Address feedback and refactor CLI overrides Simplify global initialization Add configurable config file location
- Loading branch information
1 parent
aa63a65
commit ef9ebd6
Showing
32 changed files
with
870 additions
and
620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use std::collections::HashMap; | ||
|
||
use anyhow::{bail, Result}; | ||
use camino::Utf8PathBuf; | ||
use lurk::cli::paths::lurk_default_dir; | ||
use lurk::config::lurk_config; | ||
use once_cell::sync::Lazy; | ||
|
||
/// Temporary cache location that persists until reboot or other cleanup process, | ||
/// so the user can run multiple benchmarks without regenerating params each time | ||
pub const PUBLIC_PARAMS_BENCH_PATH: &str = "/var/tmp/lurk_benches/public_params"; | ||
|
||
/// Edit this path to use a config file specific to benchmarking | ||
/// E.g. `Utf8PathBuf::from("/home/<user>/lurk-rs/lurk-bench.toml");` | ||
pub static BENCH_CONFIG_PATH: Lazy<Utf8PathBuf> = | ||
Lazy::new(|| lurk_default_dir().join("lurk.toml")); | ||
|
||
/// Sets the config settings with the temporary public parameter cache location | ||
pub fn set_bench_config() -> Result<()> { | ||
let mut settings = HashMap::new(); | ||
settings.insert("public_params_dir", PUBLIC_PARAMS_BENCH_PATH.into()); | ||
let config = lurk_config(Some(&BENCH_CONFIG_PATH), Some(&settings)); | ||
// If global config already set, check it has the same | ||
// temporary public param cache or return an error | ||
if config.public_params_dir == PUBLIC_PARAMS_BENCH_PATH { | ||
Ok(()) | ||
} else { | ||
bail!( | ||
"Incorrect public parameter cache directory: {}", | ||
config.public_params_dir | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.