Skip to content

Commit

Permalink
fix: also error on 20 block sync attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelPretorius committed Sep 26, 2024
1 parent 206b125 commit 3c0412a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/sync/sync_blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,14 @@ export const startSync = async () => {
currentBlock++;
} else {
count++;
// if count is 10, log that already on 10th attempt
if (count === 10) {
console.log(`Next block, 10th attempt: ${currentBlock}`);
}
// if count is more than 20, error out to indicate something might be wrong
if (count > 20) {
throw new Error("More than 20 attempts in a row, erroring...");
}
await sleep(1100);
}
errorCount = 0;
Expand All @@ -104,7 +109,7 @@ export const startSync = async () => {

// if more than 5 errors in a row, exit
if (errorCount > 5) {
console.error("Errors for more than 10 times in a row, exiting");
console.error("Errors for more than 10 times in a row, exiting...");
throw error;
}
}
Expand Down

0 comments on commit 3c0412a

Please sign in to comment.