Skip to content

Commit

Permalink
Replace directories dependency with home, known-folders, xdg
Browse files Browse the repository at this point in the history
`directories 5.0.1` added a dependency on `option-ext`, which is
licensed as MPL (a copyleft license). The replacement dependencies
are all licensed as `MIT OR Apache-2.0`.
  • Loading branch information
str4d committed Jun 28, 2023
1 parent fa67d9a commit 3de60c7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
3 changes: 3 additions & 0 deletions zcash_proofs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this library adheres to Rust's notion of
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Replaced internal `directories` dependency which now transitively depends on
MPL-licensed code.

## [0.12.0] - 2023-06-06
### Changed
Expand Down
5 changes: 4 additions & 1 deletion zcash_proofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ tracing = "0.1"
# Dependencies used internally:
# (Breaking upgrades to these are usually backwards-compatible, but check MSRVs.)
blake2b_simd = "1"
directories = { version = "5", optional = true }
home = { version = "0.5", optional = true }
known-folders = { version = "1", optional = true }
redjubjub = "0.7"
wagyu-zcash-parameters = { version = "0.2", optional = true }
xdg = { version = "2.5", optional = true }

[dev-dependencies]
byteorder = "1"
Expand All @@ -49,6 +51,7 @@ pprof = { version = "0.11", features = ["criterion", "flamegraph"] } # MSRV 1.56
[features]
default = ["local-prover", "multicore"]
bundled-prover = ["wagyu-zcash-parameters"]
directories = ["dep:home", "dep:known-folders", "dep:xdg"]
download-params = ["minreq", "directories"]
local-prover = ["directories"]
multicore = ["bellman/multicore", "zcash_primitives/multicore"]
Expand Down
26 changes: 17 additions & 9 deletions zcash_proofs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ use std::fs::File;
use std::io::{self, BufReader};
use std::path::Path;

#[cfg(feature = "directories")]
use directories::BaseDirs;
#[cfg(feature = "directories")]
use std::path::PathBuf;

Expand Down Expand Up @@ -77,13 +75,23 @@ pub struct SaplingParameterPaths {
#[cfg(feature = "directories")]
#[cfg_attr(docsrs, doc(cfg(feature = "directories")))]
pub fn default_params_folder() -> Option<PathBuf> {
BaseDirs::new().map(|base_dirs| {
if cfg!(any(windows, target_os = "macos")) {
base_dirs.data_dir().join("ZcashParams")
} else {
base_dirs.home_dir().join(".zcash-params")
}
})
#[cfg(windows)]
{
use known_folders::{get_known_folder_path, KnownFolder};
get_known_folder_path(KnownFolder::RoamingAppData).map(|base| base.join("ZcashParams"))
}

#[cfg(target_os = "macos")]
{
xdg::BaseDirectories::new()
.ok()
.map(|base_dirs| base_dirs.get_data_home().join("ZcashParams"))
}

#[cfg(not(any(windows, target_os = "macos")))]
{
home::home_dir().map(|base| base.join(".zcash-params"))
}
}

/// Download the Zcash Sapling parameters if needed, and store them in the default location.
Expand Down

0 comments on commit 3de60c7

Please sign in to comment.