Skip to content

Commit

Permalink
improve the check
Browse files Browse the repository at this point in the history
  • Loading branch information
moodysalem committed Oct 29, 2024
1 parent 91b6f08 commit e1a87db
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ const refreshAnalyticalTables = throttle(
for (const encodedBlockData of message.data.data) {
const block = starknet.Block.decode(encodedBlockData);

const blockTime = new Date(
Number(parseLong(block.header.timestamp.seconds) * 1000n)
);

const blockNumber = Number(parseLong(block.header.blockNumber));
deletedCount += await dao.deleteOldBlockNumbers(blockNumber);

Expand All @@ -134,12 +138,8 @@ const refreshAnalyticalTables = throttle(
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;
blockTime.getTime() > Date.now() - 300_000;

const blockTime = new Date(
Number(parseLong(block.header.timestamp.seconds) * 1000n)
);
await dao.insertBlock({
hash: FieldElement.toBigInt(block.header.blockHash),
number: parseLong(block.header.blockNumber),
Expand Down

0 comments on commit e1a87db

Please sign in to comment.