Skip to content

Commit 87c381e

Browse files
committed
handle FailedParsingVssValue when wait device lock syncing, usually it's a failure to parse because it doesn't exist.
1 parent cc2fa1c commit 87c381e

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

Diff for: mutiny-core/src/lib.rs

+25-8
Original file line numberDiff line numberDiff 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");

0 commit comments

Comments
 (0)