@@ -81,7 +81,6 @@ impl VssStore {
8181 base_url : String , store_id : String , vss_seed : [ u8 ; 32 ] ,
8282 header_provider : Arc < dyn VssHeaderProvider > , runtime : Arc < Runtime > ,
8383 ) -> Self {
84- let inner = Arc :: new ( VssStoreInner :: new ( base_url, store_id, vss_seed, header_provider) ) ;
8584 let next_version = AtomicU64 :: new ( 1 ) ;
8685 let internal_runtime = Some (
8786 tokio:: runtime:: Builder :: new_multi_thread ( )
@@ -97,6 +96,33 @@ impl VssStore {
9796 . unwrap ( ) ,
9897 ) ;
9998
99+ let schema_version = VssSchemaVersion :: V0 ;
100+ let ( data_encryption_key, obfuscation_master_key) =
101+ derive_data_encryption_and_obfuscation_keys ( & vss_seed) ;
102+ let key_obfuscator = KeyObfuscator :: new ( obfuscation_master_key) ;
103+ let retry_policy = ExponentialBackoffRetryPolicy :: new ( Duration :: from_millis ( 10 ) )
104+ . with_max_attempts ( 10 )
105+ . with_max_total_delay ( Duration :: from_secs ( 15 ) )
106+ . with_max_jitter ( Duration :: from_millis ( 10 ) )
107+ . skip_retry_on_error ( Box :: new ( |e : & VssError | {
108+ matches ! (
109+ e,
110+ VssError :: NoSuchKeyError ( ..)
111+ | VssError :: InvalidRequestError ( ..)
112+ | VssError :: ConflictError ( ..)
113+ )
114+ } ) as _ ) ;
115+
116+ let client = VssClient :: new_with_headers ( base_url, retry_policy, header_provider) ;
117+
118+ let inner = Arc :: new ( VssStoreInner :: new (
119+ schema_version,
120+ client,
121+ store_id,
122+ data_encryption_key,
123+ key_obfuscator,
124+ ) ) ;
125+
100126 Self { inner, next_version, runtime, internal_runtime }
101127 }
102128
@@ -337,27 +363,9 @@ struct VssStoreInner {
337363
338364impl VssStoreInner {
339365 pub ( crate ) fn new (
340- base_url : String , store_id : String , vss_seed : [ u8 ; 32 ] ,
341- header_provider : Arc < dyn VssHeaderProvider > ,
366+ schema_version : VssSchemaVersion , client : VssClient < CustomRetryPolicy > , store_id : String ,
367+ data_encryption_key : [ u8 ; 32 ] , key_obfuscator : KeyObfuscator ,
342368 ) -> Self {
343- let schema_version = VssSchemaVersion :: V0 ;
344- let ( data_encryption_key, obfuscation_master_key) =
345- derive_data_encryption_and_obfuscation_keys ( & vss_seed) ;
346- let key_obfuscator = KeyObfuscator :: new ( obfuscation_master_key) ;
347- let retry_policy = ExponentialBackoffRetryPolicy :: new ( Duration :: from_millis ( 10 ) )
348- . with_max_attempts ( 10 )
349- . with_max_total_delay ( Duration :: from_secs ( 15 ) )
350- . with_max_jitter ( Duration :: from_millis ( 10 ) )
351- . skip_retry_on_error ( Box :: new ( |e : & VssError | {
352- matches ! (
353- e,
354- VssError :: NoSuchKeyError ( ..)
355- | VssError :: InvalidRequestError ( ..)
356- | VssError :: ConflictError ( ..)
357- )
358- } ) as _ ) ;
359-
360- let client = VssClient :: new_with_headers ( base_url, retry_policy, header_provider) ;
361369 let locks = Mutex :: new ( HashMap :: new ( ) ) ;
362370 Self { schema_version, client, store_id, data_encryption_key, key_obfuscator, locks }
363371 }
0 commit comments