-
Notifications
You must be signed in to change notification settings - Fork 1
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 #6 from sanbir/main
retry
- Loading branch information
Showing
2 changed files
with
16 additions
and
11 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,19 +1,24 @@ | ||
import axios from 'axios' | ||
import { logger } from '../../common/helpers/logger' | ||
import { sleep } from '../../common/helpers/sleep' | ||
|
||
export async function getIsValidatorExited(pubkey: string) { | ||
export async function getIsValidatorExited(pubkey: string): Promise<boolean> { | ||
logger.info('getIsValidatorExited started for ' + pubkey) | ||
|
||
if (!process.env.BEACON_URL) { | ||
throw new Error('No BEACON_URL in ENV') | ||
} | ||
|
||
const result = await axios.get( | ||
process.env.BEACON_URL! + '/eth/v1/beacon/states/head/validators/' + pubkey, | ||
) | ||
|
||
const isExited = result.data.data.status === 'withdrawal_done' | ||
|
||
logger.info('getIsValidatorExited finished for ' + pubkey + ' ' + isExited) | ||
return isExited | ||
try { | ||
const result = await axios.get( | ||
process.env.BEACON_URL! + '/eth/v1/beacon/states/head/validators/' + pubkey, | ||
) | ||
const isExited = result.data.data.status === 'withdrawal_done' | ||
logger.info('getIsValidatorExited finished for ' + pubkey + ' ' + isExited) | ||
return isExited | ||
} catch { | ||
logger.info('Retrying....') | ||
await sleep(3000) | ||
return await getIsValidatorExited(pubkey) | ||
} | ||
} |