Skip to content
This repository has been archived by the owner on Feb 3, 2025. It is now read-only.

Commit

Permalink
release vss lock when stop is called
Browse files Browse the repository at this point in the history
  • Loading branch information
futurepaul committed Nov 11, 2023
1 parent 08f8b05 commit 36307fd
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions mutiny-core/src/nodemanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ use crate::scb::{
EncryptedSCB, StaticChannelBackup, StaticChannelBackupStorage,
SCB_ENCRYPTION_KEY_DERIVATION_PATH,
};
use crate::storage::{MutinyStorage, DEVICE_ID_KEY, KEYCHAIN_STORE_KEY, NEED_FULL_SYNC_KEY};
use crate::utils::{sleep, spawn};
use crate::storage::{MutinyStorage, DEVICE_ID_KEY, KEYCHAIN_STORE_KEY, NEED_FULL_SYNC_KEY, DEVICE_LOCK_KEY, DeviceLock};
use crate::utils::{sleep, spawn, now};
use crate::MutinyWalletConfig;
use crate::vss::VssKeyValueItem;
use crate::{
chain::MutinyChain,
error::MutinyError,
Expand Down Expand Up @@ -848,6 +849,21 @@ impl<S: MutinyStorage> NodeManager<S> {
nodes.clear();
log_debug!(self.logger, "stopped all nodes");

// release the device lock
if let Some(vss) = self.storage.vss_client() {
let device = self.storage.get_device_id()?;
// set time to 0 to unlock
let lock = DeviceLock { time: 0, device };
// still update the version so it is written to VSS
let time = now().as_secs() as u32;
let item = VssKeyValueItem {
key: DEVICE_LOCK_KEY.to_string(),
value: serde_json::to_value(lock)?,
version: time,
};
vss.put_objects(vec![item]).await?;
}

// stop the indexeddb object to close db connection
if self.storage.connected().unwrap_or(false) {
log_debug!(self.logger, "stopping storage");
Expand Down

0 comments on commit 36307fd

Please sign in to comment.