From 91b6f0826bb242f1593e75ffc39d90c040f14af5 Mon Sep 17 00:00:00 2001 From: Moody Salem Date: Tue, 29 Oct 2024 08:57:58 -0400 Subject: [PATCH] add another check for pending blocks --- src/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 07dcf00..c5d8243 100644 --- a/src/index.ts +++ b/src/index.ts @@ -119,7 +119,7 @@ const refreshAnalyticalTables = throttle( await dao.beginTransaction(); - let isPending: boolean = true; + let isPending: boolean = false; let deletedCount: number = 0; @@ -131,7 +131,11 @@ const refreshAnalyticalTables = throttle( // for pending blocks we update operational materialized views before we commit isPending = - isPending || FieldElement.toBigInt(block.header.blockHash) === 0n; + isPending || + FieldElement.toBigInt(block.header.blockHash) === 0n || + // blocks in the last 5 minutes are considered pending + parseLong(block.header.timestamp.seconds) > + Date.now() / 1000 - 300; const blockTime = new Date( Number(parseLong(block.header.timestamp.seconds) * 1000n)