From 5d2b01e08bd1456ca92edfc87b9d99ed0c01ae1e Mon Sep 17 00:00:00 2001 From: jairajdev Date: Mon, 22 Jul 2024 13:06:44 +0545 Subject: [PATCH] Put the console logs behind the verbose flag --- src/Data/Collector.ts | 17 +++++++++-------- src/Data/Cycles.ts | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Data/Collector.ts b/src/Data/Collector.ts index a668a916..3335af16 100644 --- a/src/Data/Collector.ts +++ b/src/Data/Collector.ts @@ -391,19 +391,20 @@ export const verifyReceiptData = async ( if (globalModification && config.skipGlobalTxReceiptVerification) return { success: true } const { appliedVote, signatures } = appliedReceipt const { txId, timestamp } = receipt.tx - const currentTimestamp = Date.now() - // Console log the timetaken between the receipt timestamp and the current time ( both in ms and s) - console.log( - `Time taken between receipt timestamp and current time: ${txId}`, - `${currentTimestamp - timestamp} ms`, - `${(currentTimestamp - timestamp) / 1000} s` - ) + if (config.VERBOSE) { + const currentTimestamp = Date.now() + // Console log the timetaken between the receipt timestamp and the current time ( both in ms and s) + console.log( + `Time taken between receipt timestamp and current time: ${txId}`, + `${currentTimestamp - timestamp} ms`, + `${(currentTimestamp - timestamp) / 1000} s` + ) + } const currentCycle = getCurrentCycleCounter() if (currentCycle - cycle > 2) { Logger.mainLogger.error( `Found receipt with cycle older than 2 cycles ${txId}, ${cycle}, ${timestamp}, ${currentCycle}` ) - console.dir(receipt, { depth: null }) } const cycleShardData = shardValuesByCycle.get(cycle) if (!cycleShardData) { diff --git a/src/Data/Cycles.ts b/src/Data/Cycles.ts index 139fe7f6..88f9a0a0 100644 --- a/src/Data/Cycles.ts +++ b/src/Data/Cycles.ts @@ -91,8 +91,8 @@ export async function processCycles(cycles: P2PTypes.CycleCreatorTypes.CycleData setShutdownCycleRecord(cycle) NodeList.toggleFirstNode() } - // Clean receipts/originalTxs cache that are older than 20 minutes to match with CYCLE_SHARD_STORAGE_LIMIT ( actual fix is on another branch ) - const cleanupTimestamp = Date.now() - 20 * 60 * 1000 + // Clean receipts/originalTxs cache that are older than minutes + const cleanupTimestamp = (cycle.start - config.CYCLE_SHARD_STORAGE_LIMIT * 60) * 1000 cleanOldOriginalTxsMap(cleanupTimestamp) cleanOldReceiptsMap(cleanupTimestamp) }