Skip to content

Commit

Permalink
Put the console logs behind the verbose flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jairajdev committed Jul 22, 2024
1 parent c4e001d commit 5d2b01e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions src/Data/Collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
)
console.dir(receipt, { depth: null })
}
const cycleShardData = shardValuesByCycle.get(cycle)
if (!cycleShardData) {
Expand Down
4 changes: 2 additions & 2 deletions src/Data/Cycles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <CYCLE_SHARD_STORAGE_LIMIT> minutes
const cleanupTimestamp = (cycle.start - config.CYCLE_SHARD_STORAGE_LIMIT * 60) * 1000
cleanOldOriginalTxsMap(cleanupTimestamp)
cleanOldReceiptsMap(cleanupTimestamp)
}
Expand Down

0 comments on commit 5d2b01e

Please sign in to comment.