From a5320aa02429793057b8d59ead1991fef9cfafa3 Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Wed, 4 Oct 2023 10:59:58 -0700 Subject: [PATCH] Only log waiting for block height if timed out. --- src/scripts/export/trace.ts | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/scripts/export/trace.ts b/src/scripts/export/trace.ts index 185d58bf..2ba83c2c 100644 --- a/src/scripts/export/trace.ts +++ b/src/scripts/export/trace.ts @@ -119,18 +119,6 @@ const trace = async () => { if (!blockHeightToTimeCache.has(blockHeight) && webSocketConnected) { const blockHeights = blockHeightToTimeCache.dump().map(([key]) => key) if (blockHeights.every((b) => b < blockHeight)) { - const earliestBlockHeight = blockHeights.reduce( - (acc, curr) => (curr < acc ? curr : acc), - Infinity - ) - const latestBlockHeight = blockHeights.reduce( - (acc, curr) => (curr > acc ? curr : acc), - -Infinity - ) - console.log( - `[${new Date().toISOString()}] Waiting for ${blockHeight.toLocaleString()}'s time... (${earliestBlockHeight.toLocaleString()} — ${latestBlockHeight.toLocaleString()})` - ) - const time = await new Promise((resolve) => { const interval = setInterval(() => { if (blockHeightToTimeCache.has(blockHeight)) { @@ -141,6 +129,21 @@ const trace = async () => { }, 50) const timeout = setTimeout(() => { + const blockHeights = blockHeightToTimeCache + .dump() + .map(([key]) => key) + const earliestBlockHeight = blockHeights.reduce( + (acc, curr) => (curr < acc ? curr : acc), + Infinity + ) + const latestBlockHeight = blockHeights.reduce( + (acc, curr) => (curr > acc ? curr : acc), + -Infinity + ) + + console.log( + `[${new Date().toISOString()}] Timed out waiting for ${blockHeight.toLocaleString()}'s time... (${earliestBlockHeight.toLocaleString()} — ${latestBlockHeight.toLocaleString()})` + ) clearInterval(interval) resolve(undefined) }, 3000)