Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add storage stop logs #63

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 7 additions & 9 deletions mutiny-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1625,15 +1625,15 @@ impl<S: MutinyStorage> MutinyWallet<S> {
/// Stops all of the nodes and background processes.
/// Returns after node has been stopped.
pub async fn stop(&mut self) -> Result<(), MutinyError> {
log_trace!(self.logger, "calling stop");
log_debug!(self.logger, "calling stop");

let node_manager = self.node_manager.take().ok_or(MutinyError::NotRunning)?;

node_manager.stop().await?;

// store wallet
{
log_trace!(self.logger, "save wallet state");
log_debug!(self.logger, "save wallet state");
let mut wallet = node_manager
.wallet
.wallet
Expand All @@ -1644,22 +1644,20 @@ impl<S: MutinyStorage> MutinyWallet<S> {
}
}

log_trace!(self.logger, "release device lock");
log_debug!(self.logger, "release device lock");
// stop device lock
self.device_lock_stop_handle.stop().await;

log_trace!(self.logger, "stop logger");
log_debug!(self.logger, "stop logger");
// stop logger
self.logger.stop().await;

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

log_trace!(self.logger, "finished calling stop");
log_debug!(self.logger, "finished calling stop");
Ok(())
}

Expand Down Expand Up @@ -1728,15 +1726,15 @@ impl<S: MutinyStorage> MutinyWallet<S> {

/// Deletes all the storage
pub async fn delete_all(&self) -> Result<(), MutinyError> {
log_trace!(self.logger, "calling delete_all");
log_debug!(self.logger, "calling delete_all");
if self.node_manager.is_some() {
return Err(MutinyError::AlreadyRunning);
}

self.storage.stop().await;

self.storage.delete_all().await?;
log_trace!(self.logger, "finished calling delete_all");
log_debug!(self.logger, "finished calling delete_all");

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion mutiny-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cargo-features = ["per-package-target"]

[package]
name = "mutiny-wasm"
version = "1.10.20"
version = "1.10.21-rc0"
edition = "2021"
authors = ["utxostack"]
forced-target = "wasm32-unknown-unknown"
Expand Down
4 changes: 4 additions & 0 deletions mutiny-wasm/src/indexed_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ impl MutinyStorage for IndexedDbStorage {
}

async fn start(&mut self) -> Result<(), MutinyError> {
log_debug!(self.logger, "starting storage");
let indexed_db = if self.indexed_db.try_read()?.0.is_none() {
Arc::new(RwLock::new(RexieContainer(Some(
Self::build_indexed_db_database().await?,
Expand All @@ -797,6 +798,7 @@ impl MutinyStorage for IndexedDbStorage {
let memory = Arc::new(RwLock::new(map));
self.indexed_db = indexed_db;
self.memory = memory;
log_debug!(self.logger, "started storage");
Ok(())
}

Expand All @@ -816,6 +818,7 @@ impl MutinyStorage for IndexedDbStorage {
}

async fn stop(&self) {
log_debug!(self.logger, "stopping storage");
// Wait all back ground tasks
self.tasks.wait().await;

Expand All @@ -825,6 +828,7 @@ impl MutinyStorage for IndexedDbStorage {
indexed_db.close();
}
}
log_debug!(self.logger, "stopped storage");
}

fn connected(&self) -> Result<bool, MutinyError> {
Expand Down
Loading