Skip to content

Commit

Permalink
zcash_proofs: Add feature flags to docs.rs documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
str4d committed Aug 23, 2020
1 parent a3cb89d commit cda56ef
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions zcash_proofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ readme = "README.md"
license = "MIT OR Apache-2.0"
edition = "2018"

[package.metadata.docs.rs]
all-features = true

[dependencies]
bellman = { version = "0.6", path = "../bellman", default-features = false, features = ["groth16"] }
blake2b_simd = "0.5"
Expand Down
7 changes: 7 additions & 0 deletions zcash_proofs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//! `zcash_proofs` contains the zk-SNARK circuits used by Zcash, and the APIs for creating
//! and verifying proofs.
#![cfg_attr(docsrs, feature(doc_cfg))]
// Catch documentation errors caused by code changes.
#![deny(intra_doc_link_resolution_failure)]

Expand All @@ -24,6 +25,10 @@ pub mod sapling;
pub mod sprout;

#[cfg(any(feature = "local-prover", feature = "bundled-prover"))]
#[cfg_attr(
docsrs,
doc(cfg(any(feature = "local-prover", feature = "bundled-prover")))
)]
pub mod prover;

// Circuit names
Expand All @@ -42,6 +47,7 @@ const DOWNLOAD_URL: &str = "https://download.z.cash/downloads";

/// Returns the default folder that the Zcash proving parameters are located in.
#[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")) {
Expand All @@ -56,6 +62,7 @@ pub fn default_params_folder() -> Option<PathBuf> {
///
/// This mirrors the behaviour of the `fetch-params.sh` script from `zcashd`.
#[cfg(feature = "download-params")]
#[cfg_attr(docsrs, doc(cfg(feature = "download-params")))]
pub fn download_parameters() -> Result<(), minreq::Error> {
// Ensure that the default Zcash parameters location exists.
let params_dir = default_params_folder().ok_or(io::Error::new(
Expand Down
3 changes: 3 additions & 0 deletions zcash_proofs/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ impl LocalTxProver {
/// This function will panic if the paths do not point to valid parameter files with
/// the expected hashes.
#[cfg(feature = "local-prover")]
#[cfg_attr(docsrs, doc(cfg(feature = "local-prover")))]
pub fn new(spend_path: &Path, output_path: &Path) -> Self {
let (spend_params, spend_vk, output_params, _, _) =
load_parameters(spend_path, output_path, None);
Expand Down Expand Up @@ -81,6 +82,7 @@ impl LocalTxProver {
/// This function will panic if the parameters in the default local location do not
/// have the expected hashes.
#[cfg(feature = "local-prover")]
#[cfg_attr(docsrs, doc(cfg(feature = "local-prover")))]
pub fn with_default_location() -> Option<Self> {
let params_dir = default_params_folder()?;
let (spend_path, output_path) = if params_dir.exists() {
Expand All @@ -103,6 +105,7 @@ impl LocalTxProver {
/// This requires the `bundled-prover` feature, which will increase the binary size by
/// around 50 MiB.
#[cfg(feature = "bundled-prover")]
#[cfg_attr(docsrs, doc(cfg(feature = "bundled-prover")))]
pub fn bundled() -> Self {
let (spend_buf, output_buf) = wagyu_zcash_parameters::load_sapling_parameters();
let (spend_params, spend_vk, output_params, _, _) =
Expand Down

0 comments on commit cda56ef

Please sign in to comment.