Skip to content

Commit

Permalink
refactor: update dependencies and remove once_cell
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Nov 27, 2019
1 parent 447b944 commit 5082839
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 82 deletions.
77 changes: 10 additions & 67 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ storage-proofs = { git = "https://github.com/filecoin-project/rust-fil-proofs.gi
bls-signatures = { git = "https://github.com/filecoin-project/bls-signatures.git", branch = "master" }
byteorder = "1.2"
drop_struct_macro_derive = "0.4.0"
ff = "0.4"
ff = "0.5"
ffi-toolkit = "0.4.0"
libc = "0.2.58"
log = "0.4.7"
once_cell = "0.2.4"
paired = "0.16.0"
pretty_env_logger = "0.3.0"
rand = "0.4"
rand = "0.7"
rayon = "1"
anyhow = "1.0.23"

Expand Down
12 changes: 5 additions & 7 deletions rust/src/bls/api.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::slice::from_raw_parts;

use bls_signatures::{
aggregate as aggregate_sig, hash as hash_sig,
aggregate as aggregate_sig,
groupy::{CurveAffine, CurveProjective, EncodedPoint, GroupDecodingError},
hash as hash_sig,
paired::bls12_381::{G2Affine, G2Compressed},
paired::GroupDecodingError,
paired::{CurveAffine, CurveProjective, EncodedPoint},
verify as verify_sig, PrivateKey, PublicKey, Serialize, Signature,
};
use libc;
use rand::OsRng;
use rand::rngs::OsRng;

use rayon::prelude::*;

Expand Down Expand Up @@ -161,10 +161,8 @@ pub unsafe extern "C" fn verify(
/// * `raw_seed_ptr` - pointer to a seed byte array
#[no_mangle]
pub unsafe extern "C" fn private_key_generate() -> *mut types::PrivateKeyGenerateResponse {
let rng = &mut OsRng::new().expect("not enough randomness");

let mut raw_private_key: [u8; PRIVATE_KEY_BYTES] = [0; PRIVATE_KEY_BYTES];
PrivateKey::generate(rng)
PrivateKey::generate(&mut OsRng)
.write_bytes(&mut raw_private_key.as_mut())
.expect("preallocated");

Expand Down
9 changes: 4 additions & 5 deletions rust/src/proofs/api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::mem;
use std::slice::from_raw_parts;
use std::sync::Once;

use ffi_toolkit::{
c_str_to_pbuf, catch_panic_response, raw_ptr, rust_str_to_c_str, FCPResponseStatus,
Expand All @@ -10,7 +11,6 @@ use filecoin_proofs::{
PoStConfig, SectorClass, SectorSize, UnpaddedByteIndex, UnpaddedBytesAmount,
};
use libc;
use once_cell::sync::OnceCell;
use storage_proofs::hasher::pedersen::PedersenDomain;
use storage_proofs::hasher::Domain;
use storage_proofs::sector::SectorId;
Expand Down Expand Up @@ -740,13 +740,12 @@ pub unsafe extern "C" fn destroy_generate_candidates_response(
}

/// Protects the init off the logger.
static LOG_INIT: OnceCell<bool> = OnceCell::new();
static LOG_INIT: Once = Once::new();

/// Ensures the logger is initialized.
fn init_log() {
LOG_INIT.get_or_init(|| {
let _ = pretty_env_logger::try_init_timed();
true
LOG_INIT.call_once(|| {
pretty_env_logger::init_timed();
});
}

Expand Down

0 comments on commit 5082839

Please sign in to comment.