Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
Resolve sync issues (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLoneRonin authored May 27, 2021
1 parent 283bcba commit bbcec1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arweave/gateway",
"version": "0.11.2",
"version": "0.11.3",
"main": "dist/src/Gateway.js",
"repository": "[email protected]:ArweaveTeam/gateway.git",
"author": "Arweave <[email protected]>",
Expand Down
11 changes: 8 additions & 3 deletions src/database/sync.database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export async function parallelize(height: number) {
}
}

export async function storeBlock(height: number) {
export async function storeBlock(height: number, retry: number = 0) {
try {
const currentBlock = await block(height);
const {formattedBlock, input} = serializeBlock(currentBlock, height);
Expand All @@ -148,9 +148,14 @@ export async function storeBlock(height: number) {
await storeTransactions(JSON.parse(formattedBlock.txs) as Array<string>, height);
}
} catch (error) {
log.info(`[snapshot] could not retrieve block at height ${height}, retrying`);
if (SIGKILL === false) {
await storeBlock(height);
if (retry >= 3) {
log.info(`[snapshot] there were problems retrieving ${height}, restarting the server`);
process.exit();
} else {
log.info(`[snapshot] could not retrieve block at height ${height}, retrying`);
await storeBlock(height, retry + 1);
}
}
}
}
Expand Down

0 comments on commit bbcec1e

Please sign in to comment.