Skip to content

Commit

Permalink
feat: add latest shown time logging
Browse files Browse the repository at this point in the history
  • Loading branch information
InfoIsland committed Apr 9, 2024
1 parent 85e49d6 commit bebdddf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class Tracker {
latestTip = '';
blocksByHash: Record<string, BlockData> = {};
blocksByHeight: Record<number, string[]> = {};
latestBlockShownTime = Date.now();

async fetch_and_save_block(block_number: number) {
const block = await pRetry(() => get_block(block_number), {
Expand Down Expand Up @@ -174,7 +175,13 @@ class Tracker {
console.log(`Reorg tip found: ${latestTip}`);
}
} else {
console.log(`Next block shown: ${latestHeight}`);
console.log(
`Next block shown: ${latestHeight}, duration: ${
(Date.now() - this.latestBlockShownTime) / 1000
}s`
);

this.latestBlockShownTime = Date.now();
}

this.latestHeight = latestHeight;
Expand Down

0 comments on commit bebdddf

Please sign in to comment.