@@ -112,15 +112,13 @@ impl VssStore {
112112 ) ;
113113
114114 let runtime_handle = internal_runtime. handle ( ) ;
115- let schema_store_id = store_id. clone ( ) ;
116- let schema_key_obfuscator = KeyObfuscator :: new ( obfuscation_master_key) ;
117- let ( schema_version, blocking_client) = tokio:: task:: block_in_place ( move || {
115+ let schema_version = tokio:: task:: block_in_place ( || {
118116 runtime_handle. block_on ( async {
119117 determine_and_write_schema_version (
120- blocking_client,
121- schema_store_id ,
118+ & blocking_client,
119+ & store_id ,
122120 data_encryption_key,
123- schema_key_obfuscator ,
121+ & key_obfuscator ,
124122 )
125123 . await
126124 } )
@@ -674,13 +672,10 @@ fn retry_policy() -> CustomRetryPolicy {
674672 } ) as _ )
675673}
676674
677- // FIXME: This returns the used client as currently `VssClient`'s `RetryPolicy`s aren't `Clone`. So
678- // we're forced to take the owned client and return it to be able to reuse the same connection
679- // later.
680675async fn determine_and_write_schema_version (
681- client : VssClient < CustomRetryPolicy > , store_id : String , data_encryption_key : [ u8 ; 32 ] ,
682- key_obfuscator : KeyObfuscator ,
683- ) -> io:: Result < ( VssSchemaVersion , VssClient < CustomRetryPolicy > ) > {
676+ client : & VssClient < CustomRetryPolicy > , store_id : & String , data_encryption_key : [ u8 ; 32 ] ,
677+ key_obfuscator : & KeyObfuscator ,
678+ ) -> io:: Result < VssSchemaVersion > {
684679 // Build the obfuscated `vss_schema_version` key.
685680 let obfuscated_prefix = key_obfuscator. obfuscate ( & format ! { "{}#{}" , "" , "" } ) ;
686681 let obfuscated_key = key_obfuscator. obfuscate ( VSS_SCHEMA_VERSION_KEY ) ;
@@ -726,7 +721,7 @@ async fn determine_and_write_schema_version(
726721 let msg = format ! ( "Failed to decode schema version: {}" , e) ;
727722 Error :: new ( ErrorKind :: Other , msg)
728723 } ) ?;
729- Ok ( ( schema_version, client ) )
724+ Ok ( schema_version)
730725 } else {
731726 // The schema version wasn't present, this either means we're running for the first time *or* it's V0 pre-migration (predating writing of the schema version).
732727
@@ -748,7 +743,7 @@ async fn determine_and_write_schema_version(
748743 let wallet_data_present = !response. key_versions . is_empty ( ) ;
749744 if wallet_data_present {
750745 // If the wallet data is present, it means we're not running for the first time.
751- Ok ( ( VssSchemaVersion :: V0 , client ) )
746+ Ok ( VssSchemaVersion :: V0 )
752747 } else {
753748 // We're running for the first time, write the schema version to save unnecessary IOps
754749 // on future startup.
@@ -762,7 +757,7 @@ async fn determine_and_write_schema_version(
762757 storable_builder. build ( encoded_version, vss_version, & data_encryption_key, aad) ;
763758
764759 let request = PutObjectRequest {
765- store_id,
760+ store_id : store_id . clone ( ) ,
766761 global_version : None ,
767762 transaction_items : vec ! [ KeyValue {
768763 key: store_key,
@@ -777,7 +772,7 @@ async fn determine_and_write_schema_version(
777772 Error :: new ( ErrorKind :: Other , msg)
778773 } ) ?;
779774
780- Ok ( ( schema_version, client ) )
775+ Ok ( schema_version)
781776 }
782777 }
783778}
0 commit comments