fn contribute_to_params(path_before: &str, seed: Option<[u8; 32]>) {
    let (proof, hasher, sector_size, head, prev_param_number, param_size, read_raw) =
        parse_params_filename(path_before);

    let param_number = prev_param_number + 1;

    info!(
        "contributing to params for circuit: {}-{}-{}-{}-{} {}->{}",
        proof.pretty_print(),
        hasher.pretty_print(),
        sector_size.pretty_print(),
        head,
        param_size.pretty_print(),
        prev_param_number,
        param_number
    );

    // Get OS entropy prior to deserializing the previous params.
    let seed = if let Some(seed) = seed {
        warn!("using `seed` argument as entropy: {}", hex_string(&seed));
        seed
    } else {
        info!("using mixed entropy");
        get_mixed_entropy()
    };
    let mut rng = ChaChaRng::from_seed(seed);

    // Write small-raw contributions.
    let path_after = params_filename(
        proof,
        hasher,
        sector_size,
        &head,
        param_number,
        ParamSize::Small,
        true,
    );

    let start_total = Instant::now();

    info!("making contribution");
    let start_contrib = Instant::now();

    let mut streamer = if param_size.is_large() {
        Streamer::new_from_large_file(path_before, read_raw, true).unwrap_or_else(|e| {
            panic!(
                "failed to make streamer from large `{}`: {}",
                path_before, e
            );
        })
    } else {
        Streamer::new(path_before, read_raw, true).unwrap_or_else(|e| {
            panic!(
                "failed to make streamer from small `{}`: {}",
                path_before, e
            );
        })
    };

    let file_after = File::create(&path_after).unwrap_or_else(|e| {
        panic!(
            "failed to create 'after' params file `{}`: {}",
            path_after, e
        );
    });

    info!("streaming 'after' params to file: {}", path_after);
    let contrib = streamer
        .contribute(&mut rng, file_after, CHUNK_SIZE)
        .unwrap_or_else(|e| panic!("failed to make streaming contribution: {}", e));

    let contrib_str = hex_string(&contrib);
    info!(
        "successfully made contribution: {}, dt_contribute={}s",
        contrib_str,
        start_contrib.elapsed().as_secs()
    );

    let contrib_path = format!("{}.contrib", path_after);
    info!("writing contribution hash to file: {}", contrib_path);
    fs::write(&contrib_path, contrib_str).unwrap_or_else(|e| {
        panic!(
            "failed to write contribution to file `{}`: {}",
            contrib_path, e
        );
    });

    info!(
        "successfully made contribution, dt_total={}s",
        start_total.elapsed().as_secs()
    );
}
/// Contributes entropy to the current phase2 parameters for a circuit, then writes the new params
/// to a small-raw file.
Contributes entropy to the current phase2 parameters for a circuit, then writes the new params
to a small-raw file.
Contributes entropy to the current phase2 parameters for a circuit then writes the new params to a small - raw file .
fn contribute_to_params(path_before: &str, seed: Option<[u8; 32]>) {
    let (proof, hasher, sector_size, head, prev_param_number, param_size, read_raw) =
        parse_params_filename(path_before);
    let param_number = prev_param_number + 1;
    info!(
        "contributing to params for circuit: {}-{}-{}-{}-{} {}->{}",
        proof.pretty_print(),
        hasher.pretty_print(),
        sector_size.pretty_print(),
        head,
        param_size.pretty_print(),
        prev_param_number,
        param_number
    );
    // Get OS entropy prior to deserializing the previous params.
    let seed = if let Some(seed) = seed {
        warn!("using `seed` argument as entropy: {}", hex_string(&seed));
        seed
    } else {
        info!("using mixed entropy");
        get_mixed_entropy()
    };
    let mut rng = ChaChaRng::from_seed(seed);
    // Write small-raw contributions.
    let path_after = params_filename(
        proof,
        hasher,
        sector_size,
        &head,
        param_number,
        ParamSize::Small,
        true,
    );
    let start_total = Instant::now();
    info!("making contribution");
    let start_contrib = Instant::now();
    let mut streamer = if param_size.is_large() {
        Streamer::new_from_large_file(path_before, read_raw, true).unwrap_or_else(|e| {
            panic!(
                "failed to make streamer from large `{}`: {}",
                path_before, e
            );
        })
    } else {
        Streamer::new(path_before, read_raw, true).unwrap_or_else(|e| {
            panic!(
                "failed to make streamer from small `{}`: {}",
                path_before, e
            );
        })
    };
    let file_after = File::create(&path_after).unwrap_or_else(|e| {
        panic!(
            "failed to create 'after' params file `{}`: {}",
            path_after, e
        );
    });
    info!("streaming 'after' params to file: {}", path_after);
    let contrib = streamer
        .contribute(&mut rng, file_after, CHUNK_SIZE)
        .unwrap_or_else(|e| panic!("failed to make streaming contribution: {}", e));
    let contrib_str = hex_string(&contrib);
    info!(
        "successfully made contribution: {}, dt_contribute={}s",
        contrib_str,
        start_contrib.elapsed().as_secs()
    );
    let contrib_path = format!("{}.contrib", path_after);
    info!("writing contribution hash to file: {}", contrib_path);
    fs::write(&contrib_path, contrib_str).unwrap_or_else(|e| {
        panic!(
            "failed to write contribution to file `{}`: {}",
            contrib_path, e
        );
    });
    info!(
        "successfully made contribution, dt_total={}s",
        start_total.elapsed().as_secs()
    );
}
fn contribute_to_params ( path_before : & str , seed : Option < [ u8 ; 32 ] > ) { let ( proof , hasher , sector_size , head , prev_param_number , param_size , read_raw ) = parse_params_filename ( path_before ) ; let param_number = prev_param_number + 1 ; info ! ( " " proof pretty_print ( ) hasher pretty_print ( ) sector_size pretty_print ( ) head param_size pretty_print ( ) prev_param_number param_number ) ; // Get OS entropy prior to deserializing the previous params. let seed = if let Some ( seed ) = seed { warn ! ( " " hex_string ( seed ) ) ; seed } else { info ! ( " " ) ; get_mixed_entropy ( ) } ; let mut rng = ChaChaRng :: from_seed ( seed ) ; // Write small-raw contributions. let path_after = params_filename ( proof , hasher , sector_size , & head , param_number , ParamSize :: Small , true , ) ; let start_total = Instant :: now ( ) ; info ! ( " " ) ; let start_contrib = Instant :: now ( ) ; let mut streamer = if param_size . is_large ( ) { Streamer :: new_from_large_file ( path_before , read_raw , true ) . unwrap_or_else ( | e | { panic ! ( " " path_before e ) ; } ) } else { Streamer :: new ( path_before , read_raw , true ) . unwrap_or_else ( | e | { panic ! ( " " path_before e ) ; } ) } ; let file_after = File :: create ( & path_after ) . unwrap_or_else ( | e | { panic ! ( " " path_after e ) ; } ) ; info ! ( " " path_after ) ; let contrib = streamer . contribute ( & mut rng , file_after , CHUNK_SIZE ) . unwrap_or_else ( | e | panic ! ( " " e ) ) ; let contrib_str = hex_string ( & contrib ) ; info ! ( " " contrib_str start_contrib elapsed ( ) as_secs ( ) ) ; let contrib_path = format ! ( " " path_after ) ; info ! ( " " contrib_path ) ; fs :: write ( & contrib_path , contrib_str ) . unwrap_or_else ( | e | { panic ! ( " " contrib_path e ) ; } ) ; info ! ( " " start_total elapsed ( ) as_secs ( ) ) ; }
Contributes entropy to the current phase2 parameters for a circuit, then writes the new params
to a small-raw file.
Contributes entropy to the current phase2 parameters for a circuit then writes the new params to a small - raw file .
path_before
&str
seed
Option<[u8; 32]>
path_before
&str
seed
Option<[u8; 32]>