This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from jchen86/lodestar-multiple-keys
Fix multiple issues that causes app to crash
- Loading branch information
Showing
3 changed files
with
46 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,23 @@ | ||
export const validatorShortName = (pubkey) => pubkey.slice(2,9); | ||
export const validatorShortName = (pubkey) => pubkey.slice(2, 9); | ||
|
||
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms)) | ||
|
||
export async function withRetry(fn, options = {}) { | ||
const { maxAttempts = 5, interval = 3000 } = options; | ||
let attempts = 0; | ||
|
||
while (attempts < maxAttempts) { | ||
try { | ||
return await fn(); | ||
} catch (err) { | ||
attempts++; | ||
console.warn(`${attempts} of ${maxAttempts} attempts failed with error: ${err}`); | ||
|
||
if (attempts == maxAttempts) { | ||
throw new Error(`Failed after ${attempts} attempts: ${err}`); | ||
} | ||
|
||
await sleep(interval); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters