Skip to content

Commit bb95d86

Browse files
refactor: Make environment variable name public (#367)
This environment variable is used downstream in neptune-core to make decisions based on the padded height, whether to use the RAM frugal ("no_cache") or RAM hungry ("cache") pathway.. Instead of repeating the name downstream, it's better to use it from a constant exposed in this repo. Cf. bbe04bc16ee78f1edf1fd957ea0f41c2d6f5f9a7. Also makes the two possible values for this environment variable public: "cache" and "no_cache".
1 parent dfe5b5f commit bb95d86

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

triton-vm/src/config.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ use std::cell::RefCell;
2121

2222
use arbitrary::Arbitrary;
2323

24+
pub const ENV_VAR_LDE_CACHE: &str = "TVM_LDE_TRACE";
25+
pub const ENV_VAR_LDE_CACHE_WITH_CACHE: &str = "cache";
26+
pub const ENV_VAR_LDE_CACHE_NO_CACHE: &str = "no_cache";
27+
2428
thread_local! {
2529
pub(crate) static CONFIG: RefCell<Config> = RefCell::new(Config::default());
2630
}
@@ -45,10 +49,10 @@ struct Config {
4549

4650
impl Config {
4751
pub fn new() -> Self {
48-
let maybe_overwrite = std::env::var("TVM_LDE_TRACE").map(|s| s.to_ascii_lowercase());
52+
let maybe_overwrite = std::env::var(ENV_VAR_LDE_CACHE).map(|s| s.to_ascii_lowercase());
4953
let cache_lde_trace_overwrite = match maybe_overwrite {
50-
Ok(t) if &t == "cache" => Some(CacheDecision::Cache),
51-
Ok(f) if &f == "no_cache" => Some(CacheDecision::NoCache),
54+
Ok(t) if t == ENV_VAR_LDE_CACHE_WITH_CACHE => Some(CacheDecision::Cache),
55+
Ok(f) if f == ENV_VAR_LDE_CACHE_NO_CACHE => Some(CacheDecision::NoCache),
5256
_ => None,
5357
};
5458

0 commit comments

Comments
 (0)