File tree Expand file tree Collapse file tree 6 files changed +33
-11
lines changed Expand file tree Collapse file tree 6 files changed +33
-11
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,8 @@ pub enum MutinyError {
176176 /// Failed to authenticate using JWT
177177 #[ error( "Failed to authenticate using JWT." ) ]
178178 JwtAuthFailure ,
179+ #[ error( "Failed to parse VSS value from getObject response." ) ]
180+ FailedParsingVssValue ,
179181 #[ error( transparent) ]
180182 Other ( anyhow:: Error ) ,
181183}
Original file line number Diff line number Diff line change @@ -840,19 +840,36 @@ impl<S: MutinyStorage> MutinyWalletBuilder<S> {
840840 let device_id = self . storage . get_device_id ( ) ?;
841841 let max_retries = 10 ;
842842 let mut retries = 0 ;
843- while !self
844- . storage
845- . fetch_device_lock ( )
846- . await ?
847- . is_some_and ( |lock| lock. is_last_locker ( & device_id) )
848- {
843+ while retries <= max_retries {
849844 log_info ! ( logger, "Waiting device lock syncing... {retries}" ) ;
845+
846+ match self . storage . fetch_device_lock ( ) . await {
847+ Ok ( lock_option) => {
848+ if let Some ( lock) = lock_option {
849+ if lock. is_last_locker ( & device_id) {
850+ break ;
851+ }
852+ }
853+ }
854+ Err ( MutinyError :: FailedParsingVssValue ) => {
855+ log_info ! ( logger, "Failed to parse VSS value, retrying... {retries}" ) ;
856+ }
857+ Err ( e) => {
858+ log_error ! ( logger, "Error fetching device lock: {:?}" , e) ;
859+ return Err ( e) ;
860+ }
861+ }
862+
850863 retries += 1 ;
864+
851865 if retries > max_retries {
852- log_error ! ( logger, "Can't syncing device lock to VSS" ) ;
866+ log_error ! (
867+ logger,
868+ "Can't sync device lock to VSS after {max_retries} attempts"
869+ ) ;
853870 return Err ( MutinyError :: AlreadyRunning ) ;
854871 }
855- sleep ( 300 ) . await
872+ sleep ( 300 ) . await ;
856873 }
857874 }
858875 log_debug ! ( logger, "finished checking device lock" ) ;
Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ impl MutinyVssClient {
168168 . await
169169 . map_err ( |e| {
170170 log_error ! ( self . logger, "Error parsing get objects response: {e}" ) ;
171- MutinyError :: Other ( anyhow ! ( "Error parsing get objects response: {e}" ) )
171+ MutinyError :: FailedParsingVssValue
172172 } ) ?;
173173
174174 result. decrypt ( & self . encryption_key )
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ cargo-features = ["per-package-target"]
22
33[package ]
44name = " mutiny-wasm"
5- version = " 1.10.25 "
5+ version = " 1.10.26 "
66edition = " 2021"
77authors = [" utxostack" ]
88forced-target = " wasm32-unknown-unknown"
Original file line number Diff line number Diff line change @@ -186,6 +186,8 @@ pub enum MutinyJsError {
186186 InvalidHex ,
187187 #[ error( "JWT Auth Failure" ) ]
188188 JwtAuthFailure ,
189+ #[ error( "Failed to parse VSS value from getObject response." ) ]
190+ FailedParsingVssValue ,
189191 /// Unknown error.
190192 #[ error( "Unknown Error" ) ]
191193 UnknownError ,
@@ -252,6 +254,7 @@ impl From<MutinyError> for MutinyJsError {
252254 MutinyError :: InvalidPsbt => MutinyJsError :: InvalidPsbt ,
253255 MutinyError :: InvalidHex => MutinyJsError :: InvalidHex ,
254256 MutinyError :: JwtAuthFailure => MutinyJsError :: JwtAuthFailure ,
257+ MutinyError :: FailedParsingVssValue => MutinyJsError :: FailedParsingVssValue ,
255258 }
256259 }
257260}
You can’t perform that action at this time.
0 commit comments