Skip to content

Commit

Permalink
mint connect max retries
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Aug 15, 2024
1 parent d32bac3 commit 2b0e6d9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/stores/mints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export const useMintsStore = defineStore("mints", {
showRemoveMintDialog: false,
showMintInfoDialog: false,
showMintInfoData: {} as Mint,
mintReconnectRetries: 0,
mintReconnectMaxRetries: 3,
};
},
getters: {
Expand Down Expand Up @@ -268,6 +270,12 @@ export const useMintsStore = defineStore("mints", {
}
},
activateMint: async function (mint: Mint, verbose = false, force = false) {
if (this.mintReconnectRetries >= this.mintReconnectMaxRetries) {
notifyError("Could not connect to mint.");
return;
}
this.mintReconnectRetries++;

const workers = useWorkersStore();
if (mint.url === this.activeMintUrl && !force) {
// return here because this function is called repeatedly by the
Expand All @@ -283,17 +291,18 @@ export const useMintsStore = defineStore("mints", {
try {
this.activeMintUrl = mint.url;
console.log("### this.activeMintUrl", this.activeMintUrl);
mint.info = await this.fetchMintInfo(mint);
console.log("### activateMint: Mint info: ", mint.info);
mint = await this.fetchMintKeys(mint);
this.toggleActiveUnitForMint(mint);
mint.info = await this.fetchMintInfo(mint);
console.log("### activateMint: Mint info: ", mint.info);
if (verbose) {
await notifySuccess("Mint activated.");
}
console.log(
"### activateMint: Mint activated: ",
this.activeMintUrl,
);
this.mintReconnectRetries = 0;
} catch (error: any) {
// restore previous values because the activation errored
this.activeMintUrl = previousUrl;
Expand Down

0 comments on commit 2b0e6d9

Please sign in to comment.