Skip to content

Commit

Permalink
Change ATTEMPTS back to RETRIES
Browse files Browse the repository at this point in the history
  • Loading branch information
upbqdn committed Apr 6, 2023
1 parent f2f4a53 commit 4208704
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions zebra-consensus/src/primitives/groth16/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use crate::BoxError;
/// But `zebrad start` downloads blocks at the same time, so we allow some extra time.
pub const PARAMETER_DOWNLOAD_TIMEOUT: u64 = 60 * 60;

/// The maximum number of times Zebra tries to download the parameters.
/// The maximum number of times Zebra retries to download the parameters.
///
/// Zebra will retry the download only if the previous attempt fails.
pub const PARAMETER_DOWNLOAD_MAX_ATTEMPTS: usize = 3;
pub const PARAMETER_DOWNLOAD_MAX_RETRIES: usize = 2;

lazy_static::lazy_static! {
/// Groth16 Zero-Knowledge Proof parameters for the Sapling and Sprout circuits.
Expand Down Expand Up @@ -68,7 +68,7 @@ impl Groth16Parameters {
/// # Panics
///
/// - If the parameters were downloaded to a wrong path.
/// - After [`PARAMETER_DOWNLOAD_MAX_ATTEMPTS`] failed download attempts.
/// - After [`PARAMETER_DOWNLOAD_MAX_RETRIES`] failed download retries.
/// - If the downloaded or pre-existing parameter files are invalid.
fn new() -> Groth16Parameters {
let params_directory = Groth16Parameters::directory();
Expand Down Expand Up @@ -123,7 +123,7 @@ impl Groth16Parameters {
/// # Panics
///
/// - If the parameters were downloaded to a wrong path.
/// - After [`PARAMETER_DOWNLOAD_MAX_ATTEMPTS`] failed download attempts.
/// - After [`PARAMETER_DOWNLOAD_MAX_RETRIES`] failed download retries.
fn download_sapling_parameters(sapling_spend_path: &Path, sapling_output_path: &Path) {
// TODO: instead of the path check, add a zcash_proofs argument to skip hashing existing files
// (we check them on load anyway)
Expand All @@ -136,10 +136,10 @@ impl Groth16Parameters {
sapling_output_path,
) {
retries += 1;
if retries >= PARAMETER_DOWNLOAD_MAX_ATTEMPTS {
if retries > PARAMETER_DOWNLOAD_MAX_RETRIES {
panic!(
"error downloading Sapling parameter files after {} retries. {:?} {}",
PARAMETER_DOWNLOAD_MAX_ATTEMPTS,
PARAMETER_DOWNLOAD_MAX_RETRIES,
error,
Groth16Parameters::failure_hint(),
);
Expand Down Expand Up @@ -177,18 +177,18 @@ impl Groth16Parameters {
/// # Panics
///
/// - If the parameters were downloaded to a wrong path.
/// - After [`PARAMETER_DOWNLOAD_MAX_ATTEMPTS`] failed download attempts.
/// - After [`PARAMETER_DOWNLOAD_MAX_RETRIES`] failed download retries.
fn download_sprout_parameters(sprout_path: &Path) {
if !sprout_path.exists() {
tracing::info!("downloading Zcash Sprout parameters");

let mut retries = 0;
while let Err(error) = Groth16Parameters::download_sprout_parameters_once(sprout_path) {
retries += 1;
if retries >= PARAMETER_DOWNLOAD_MAX_ATTEMPTS {
if retries > PARAMETER_DOWNLOAD_MAX_RETRIES {
panic!(
"error downloading Sprout parameter files after {} retries. {:?} {}",
PARAMETER_DOWNLOAD_MAX_ATTEMPTS,
PARAMETER_DOWNLOAD_MAX_RETRIES,
error,
Groth16Parameters::failure_hint(),
);
Expand Down

0 comments on commit 4208704

Please sign in to comment.