Skip to content

Commit

Permalink
fix: add max-attempts for finalize
Browse files Browse the repository at this point in the history
  • Loading branch information
mindrunner committed Jan 16, 2024
1 parent 756b864 commit a088b96
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/service/sol/finalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { logger } from '../../logger'

import { connection } from './const'

// eslint-disable-next-line promise/avoid-new
const sleep = (ms: number) => new Promise((resolve) => {
setTimeout(resolve, ms)
})
const sleep = (ms: number) =>
// eslint-disable-next-line promise/avoid-new
new Promise((resolve) => {
setTimeout(resolve, ms)
})

export const finalize = async (sig: string): Promise<void> => {
let finalized = false
let attempts = 0

do {
// eslint-disable-next-line no-await-in-loop
Expand All @@ -21,8 +23,11 @@ export const finalize = async (sig: string): Promise<void> => {
finalized = true
}
else {
logger.info(`Waiting for finalization: ${status.value?.confirmations}`)
logger.info(
`(${++attempts}) Waiting for finalization: ${status.value
?.confirmations}`,
)
}
} while (!finalized)
} while (!finalized || attempts > 25)
logger.info(`finalized ${sig}`)
}

0 comments on commit a088b96

Please sign in to comment.