Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Albermonte committed May 23, 2024
1 parent 96dacf8 commit 76f13bf
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions packages/nimiq-vts/src/score.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@ export function getLiveness({ activeEpochBlockNumbers, blocksPerEpoch, fromEpoch

const n = toEpoch - fromEpoch // Total number of epochs in the window
const indexToBlockNumber = (i: number) => fromEpoch + i * blocksPerEpoch
console.log({ fromEpoch, toEpoch, weightFactor, n })
for (let i = 0; i <= n; i++) {
const index = indexToBlockNumber(i)
const isActive = activeEpochBlockNumbers.indexOf(index) ? 1 : 0
const weight = 1 - weightFactor * index / n
weightedSum += weight * isActive
weightTotal += weight
if(i < 20)
console.log(JSON.stringify({ i, isActive, weight, weightedSum, weightTotal, x: weightFactor * i / n },null, 2))
}
if (weightTotal === 0) throw new Error('Weight total is zero, cannot divide by zero')

Expand Down

0 comments on commit 76f13bf

Please sign in to comment.