Skip to content

Commit

Permalink
Merge pull request #52 from fedimint/guardian-api-retry
Browse files Browse the repository at this point in the history
fix: gracefully teardown/setup setup/consensus API
  • Loading branch information
justinmoon authored Jul 6, 2023
2 parents be47100 + 4acb4ca commit 2e95296
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions apps/guardian-ui/src/GuardianApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,10 @@ export class GuardianApi
// times, but eventually give up and just throw.
let tries = 0;
const maxTries = 10;
const attempConfirmConsensusRunning = async (): Promise<void> => {
// Explicitly start a fresh socket.
await this.shutdown();
await this.connect();
// Confirm status.
const attemptConfirmConsensusRunning = async (): Promise<void> => {
try {
await this.connect();
await this.shutdown();
const status = await this.status();
if (status.server === ServerStatus.ConsensusRunning) {
return;
Expand All @@ -308,13 +306,13 @@ export class GuardianApi
if (tries < maxTries) {
tries++;
await sleep(1000);
return attempConfirmConsensusRunning();
return attemptConfirmConsensusRunning();
} else {
throw new Error('Failed to start consensus, see logs for more info.');
}
};

return attempConfirmConsensusRunning();
return attemptConfirmConsensusRunning();
};

/*** Running RPC methods */
Expand Down

0 comments on commit 2e95296

Please sign in to comment.