11use std:: mem;
22use std:: slice:: from_raw_parts;
3+ use std:: sync:: Once ;
34
45use ffi_toolkit:: {
56 c_str_to_pbuf, catch_panic_response, raw_ptr, rust_str_to_c_str, FCPResponseStatus ,
@@ -10,7 +11,6 @@ use filecoin_proofs::{
1011 PoStConfig , SectorClass , SectorSize , UnpaddedByteIndex , UnpaddedBytesAmount ,
1112} ;
1213use libc;
13- use once_cell:: sync:: OnceCell ;
1414use storage_proofs:: hasher:: pedersen:: PedersenDomain ;
1515use storage_proofs:: hasher:: Domain ;
1616use storage_proofs:: sector:: SectorId ;
@@ -320,8 +320,11 @@ pub unsafe extern "C" fn verify_seal(
320320 let porep_bytes = super :: helpers:: try_into_porep_proof_bytes ( proof_ptr, proof_len) ;
321321
322322 let result = porep_bytes. and_then ( |bs| {
323- super :: helpers:: porep_proof_partitions_try_from_bytes ( & bs) . and_then ( |ppp| {
324- let cfg = api_types:: PoRepConfig ( api_types:: SectorSize ( sector_size) , ppp) ;
323+ super :: helpers:: porep_proof_partitions_try_from_bytes ( & bs) . and_then ( |partitions| {
324+ let cfg = api_types:: PoRepConfig {
325+ sector_size : api_types:: SectorSize ( sector_size) ,
326+ partitions,
327+ } ;
325328
326329 api_fns:: verify_seal (
327330 cfg,
@@ -419,9 +422,11 @@ pub unsafe extern "C" fn verify_post(
419422 let result = convert. and_then ( |map| {
420423 let proofs = c_to_rust_proofs ( flattened_proofs_ptr, flattened_proofs_len) ?;
421424 let winners = c_to_rust_candidates ( winners_ptr, winners_len) ?;
422-
425+ let cfg = api_types:: PoStConfig {
426+ sector_size : api_types:: SectorSize ( sector_size) ,
427+ } ;
423428 api_fns:: verify_post (
424- api_types :: PoStConfig ( api_types :: SectorSize ( sector_size ) ) ,
429+ cfg ,
425430 randomness,
426431 challenge_count,
427432 & proofs,
@@ -504,7 +509,10 @@ pub unsafe extern "C" fn generate_data_commitment(
504509 . collect ( ) ;
505510
506511 let result = api_fns:: compute_comm_d (
507- PoRepConfig ( SectorSize ( sector_size) , PoRepProofPartitions ( 0 ) ) ,
512+ PoRepConfig {
513+ sector_size : SectorSize ( sector_size) ,
514+ partitions : PoRepProofPartitions ( 0 ) ,
515+ } ,
508516 & public_pieces,
509517 ) ;
510518
@@ -545,7 +553,9 @@ pub unsafe extern "C" fn generate_candidates(
545553
546554 let result = to_private_replica_info_map ( replicas_ptr, replicas_len) . and_then ( |rs| {
547555 api_fns:: generate_candidates (
548- PoStConfig ( SectorSize ( sector_size) ) ,
556+ PoStConfig {
557+ sector_size : SectorSize ( sector_size) ,
558+ } ,
549559 randomness,
550560 challenge_count,
551561 & rs,
@@ -603,7 +613,9 @@ pub unsafe extern "C" fn generate_post(
603613
604614 let result = to_private_replica_info_map ( replicas_ptr, replicas_len) . and_then ( |rs| {
605615 api_fns:: generate_post (
606- PoStConfig ( SectorSize ( sector_size) ) ,
616+ PoStConfig {
617+ sector_size : SectorSize ( sector_size) ,
618+ } ,
607619 randomness,
608620 & rs,
609621 c_to_rust_candidates ( winners_ptr, winners_len) ?,
@@ -718,13 +730,12 @@ pub unsafe extern "C" fn destroy_generate_candidates_response(
718730}
719731
720732/// Protects the init off the logger.
721- static LOG_INIT : OnceCell < bool > = OnceCell :: new ( ) ;
733+ static LOG_INIT : Once = Once :: new ( ) ;
722734
723735/// Ensures the logger is initialized.
724736fn init_log ( ) {
725- LOG_INIT . get_or_init ( || {
726- let _ = pretty_env_logger:: try_init_timed ( ) ;
727- true
737+ LOG_INIT . call_once ( || {
738+ fil_logger:: init ( ) ;
728739 } ) ;
729740}
730741
@@ -733,13 +744,14 @@ pub mod tests {
733744 use std:: io:: { Read , Seek , SeekFrom , Write } ;
734745 use std:: os:: unix:: io:: IntoRawFd ;
735746
747+ use anyhow:: Result ;
736748 use ffi_toolkit:: { c_str_to_rust_str, FCPResponseStatus } ;
737749 use rand:: { thread_rng, Rng } ;
738750
739751 use super :: * ;
740752
741753 #[ test]
742- fn test_write_with_and_without_alignment ( ) -> Result < ( ) , failure :: Error > {
754+ fn test_write_with_and_without_alignment ( ) -> Result < ( ) > {
743755 // write some bytes to a temp file to be used as the byte source
744756 let mut rng = thread_rng ( ) ;
745757 let buf: Vec < u8 > = ( 0 ..508 ) . map ( |_| rng. gen ( ) ) . collect ( ) ;
@@ -802,7 +814,7 @@ pub mod tests {
802814 }
803815
804816 #[ test]
805- fn test_sealing ( ) -> Result < ( ) , failure :: Error > {
817+ fn test_sealing ( ) -> Result < ( ) > {
806818 // miscellaneous setup and shared values
807819 let sector_class = FFISectorClass {
808820 sector_size : 1024 ,
0 commit comments