Skip to content

Commit

Permalink
fix: Stop retries when error is insufficient funds
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimo99 committed Jan 8, 2025
1 parent b54c676 commit 6c60b60
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion relay/on_chain_publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export async function drainUpdatesInRedis(
}
isDrainRunning = true;
let failedNumber = 0;
while (true) {
while (isDrainRunning) {
try {
const lastSlotOnChain = await getSlotOnChain(smartContract, beaconApi);

Expand Down Expand Up @@ -241,6 +241,11 @@ async function handleFailure(
scopeError: string,
failedNumber: number,
): Promise<[number, boolean]> {
if (error.code === "INSUFFICIENT_FUNDS") {
log(error, `Insufficient funds in ${scopeError}`, 'STOPPING');
isDrainRunning = false;
return [failedNumber, isDrainRunning];
}
if (failedNumber > 10) {
log(error, `ERROR occurred in ${scopeError}`, 'STOPPING');
isDrainRunning = false;
Expand Down

0 comments on commit 6c60b60

Please sign in to comment.