File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -190,9 +190,7 @@ mod tests {
190190 use ahash:: HashSet ;
191191 use anyhow:: Context as _;
192192 use directories:: ProjectDirs ;
193- use std:: sync:: LazyLock ;
194193 use std:: time:: { Duration , Instant } ;
195- use tokio:: sync:: Mutex ;
196194 use url:: Url ;
197195
198196 // To run a single test: cargo test --lib filecoin_multisig_statedecodeparams_1754230255631789 -- --nocapture
@@ -201,8 +199,6 @@ mod tests {
201199 async fn rpc_regression_test_run ( name : & str ) {
202200 // Set proof parameter data dir and make sure the proofs are available
203201 {
204- static PROOF_PARAMS_LOCK : LazyLock < Mutex < ( ) > > = LazyLock :: new ( || Mutex :: new ( ( ) ) ) ;
205- let _guard = PROOF_PARAMS_LOCK . lock ( ) . await ;
206202 crate :: utils:: proofs_api:: maybe_set_proofs_parameter_cache_dir_env (
207203 & Config :: default ( ) . client . data_dir ,
208204 ) ;
Original file line number Diff line number Diff line change 1010use std:: {
1111 io:: { self , ErrorKind } ,
1212 path:: { Path , PathBuf } ,
13- sync:: Arc ,
13+ sync:: { Arc , LazyLock } ,
1414} ;
1515
1616use crate :: {
@@ -23,7 +23,10 @@ use crate::{
2323use anyhow:: { Context , bail} ;
2424use backon:: { ExponentialBuilder , Retryable } ;
2525use futures:: { AsyncWriteExt , TryStreamExt , stream:: FuturesUnordered } ;
26- use tokio:: fs:: { self } ;
26+ use tokio:: {
27+ fs:: { self } ,
28+ sync:: Mutex ,
29+ } ;
2730use tracing:: { debug, info, warn} ;
2831
2932use super :: parameters:: {
@@ -61,8 +64,15 @@ pub async fn ensure_proof_params_downloaded() -> anyhow::Result<()> {
6164 if data_dir. is_empty ( ) {
6265 anyhow:: bail!( "Proof parameter data dir is not set" ) ;
6366 }
64- get_params_default ( Path :: new ( & data_dir) , SectorSizeOpt :: Keys , false ) . await ?;
65- Ok ( ( ) )
67+ static RUN_ONCE : LazyLock < Mutex < bool > > = LazyLock :: new ( || Mutex :: new ( false ) ) ;
68+ let mut run_once = RUN_ONCE . lock ( ) . await ;
69+ if * run_once {
70+ Ok ( ( ) )
71+ } else {
72+ get_params_default ( Path :: new ( & data_dir) , SectorSizeOpt :: Keys , false ) . await ?;
73+ * run_once = true ;
74+ Ok ( ( ) )
75+ }
6676}
6777
6878/// Get proofs parameters and all verification keys for a given sector size
You can’t perform that action at this time.
0 commit comments