Skip to content

Commit

Permalink
Merge with origin/hive-engine
Browse files Browse the repository at this point in the history
  • Loading branch information
bt-cryptomancer committed Jul 20, 2022
1 parent 0bb3c76 commit cfc72bf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions find_divergent_block.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const { node } = program;

let id = 1;

async function getBlock(blockNumber) {
async function getBlock(blockNumber, tries=1) {
id += 1;
try {
return (await axios({
Expand All @@ -32,8 +32,14 @@ async function getBlock(blockNumber) {
},
})).data.result;
} catch (error) {
console.error(error);
return null;
if (tries >= 3) {
console.error(error);
return null;
} else {
console.log(`Attempt #${tries} failed, retrying...`);
await new Promise((r) => setTimeout(() => r(), 500));
return await getBlock(blockNumber, tries + 1);
}
}
}

Expand Down

0 comments on commit cfc72bf

Please sign in to comment.