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

Commit

Permalink
Merge pull request #1051 from MutinyWallet/delete-bad-federation-storage
Browse files Browse the repository at this point in the history
Don't save federation to storage until after init
  • Loading branch information
benthecarman authored Feb 22, 2024
2 parents 345b88a + 3339ece commit eac9e3d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions mutiny-core/src/federation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ impl<S: MutinyStorage> FederationClient<S> {
"Fedimint on different network {}, expected: {network}",
wallet_client.get_network()
);

// try to delete the storage for this federation
if let Err(e) = fedimint_storage.delete_store().await {
log_error!(logger, "Could not delete fedimint storage: {e}");
}

return Err(MutinyError::NetworkMismatch);
}

Expand Down
12 changes: 6 additions & 6 deletions mutiny-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2442,12 +2442,6 @@ pub(crate) async fn create_new_federation<S: MutinyStorage>(
federation_code: federation_code.clone(),
};

federation_mutex
.federations
.insert(next_federation_uuid.clone(), next_federation.clone());
federation_mutex.version += 1;
storage.insert_federations(federation_mutex.clone()).await?;

// now create the federation process and init it
let new_federation = FederationClient::new(
next_federation_uuid.clone(),
Expand All @@ -2459,6 +2453,12 @@ pub(crate) async fn create_new_federation<S: MutinyStorage>(
)
.await?;

federation_mutex
.federations
.insert(next_federation_uuid.clone(), next_federation.clone());
federation_mutex.version += 1;
storage.insert_federations(federation_mutex.clone()).await?;

let federation_id = new_federation.fedimint_client.federation_id();
let federation_name = new_federation.fedimint_client.get_meta("federation_name");
let federation_expiry_timestamp = new_federation
Expand Down

0 comments on commit eac9e3d

Please sign in to comment.