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

Don't save federation to storage until after init #1051

Merged
merged 1 commit into from
Feb 22, 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
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
Loading