From 9df7e3eaad4cb9322d9abacc0bc7dd3baf68f571 Mon Sep 17 00:00:00 2001 From: Michael Pretorius Date: Tue, 4 Jun 2024 12:51:29 +0200 Subject: [PATCH] fix: add break if block add fails --- src/postgres/client.ts | 2 +- src/sync/sync_blocks.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/postgres/client.ts b/src/postgres/client.ts index b5ef780..2a9cfbf 100644 --- a/src/postgres/client.ts +++ b/src/postgres/client.ts @@ -13,7 +13,7 @@ export const pool = new Pool({ // idleTimeoutMillis: 10000, // number of milliseconds to wait before timing out when connecting a new client // by default this is 0 which means no timeout - connectionTimeoutMillis: 1000, + connectionTimeoutMillis: 2000, ...(DATABASE_USE_SSL && { ssl: { rejectUnauthorized: false } }), // Use SSL (recommended }); diff --git a/src/sync/sync_blocks.ts b/src/sync/sync_blocks.ts index fda954f..8af3ef4 100644 --- a/src/sync/sync_blocks.ts +++ b/src/sync/sync_blocks.ts @@ -22,10 +22,12 @@ export const startSync = async () => { // if already has synced, start from next block if (currentBlock !== 1) currentBlock++; + // currentBlock = 2792944; // if need custom start block + if (logSync100Time) console.time("sync"); let count = 0; while (syncing) { - // if (currentBlock === 2001) return; + // if (currentBlock === 2792945) return; // if need custom end block // console.log("wait then get block:", currentBlock, getMemoryUsage().rss); // await sleep(4000); try { @@ -83,6 +85,7 @@ export const startSync = async () => { } } catch (error) { console.error(`ERROR::Adding Block ${currentBlock}:: ${error}`); + break; } } };