Renaming variables

This commit is contained in:
Rodrigo Q. Saramago 2022-07-11 14:25:45 +02:00
parent eda667cdcd
commit 727be9d333
No known key found for this signature in database
GPG Key ID: 9B36B2525704A359

View File

@ -197,18 +197,18 @@ export class BaseTree {
pathElements: Element[], pathElements: Element[],
leafIndices: number[], leafIndices: number[],
): boolean { ): boolean {
let layerElements = leaves let layerElements: Element[] = leaves
let layerIndices = leafIndices let layerIndices: number[] = leafIndices
let proofElements = pathElements let proofElements: Element[] = pathElements
let layerProofs = [] let layerProofs: Element[] = []
for (let level = 0; level < levels; level++) { for (let level = 0; level < levels; level++) {
for (let i = 0; i < layerIndices.length; i++) { for (let i = 0; i < layerIndices.length; i++) {
let layerHash let layerHash: string
let elIdx = layerIndices[i] let elIndex = layerIndices[i]
let neighbor = elIdx ^ 1 let leafIndex = elIndex ^ 1
if (layerIndices.includes(neighbor)) { if (layerIndices.includes(leafIndex)) {
if (elIdx % 2 === 0) { if (elIndex % 2 === 0) {
layerHash = hashFn(layerElements[0], layerElements[1]) layerHash = hashFn(layerElements[0], layerElements[1])
} else { } else {
layerHash = hashFn(layerElements[1], layerElements[0]) layerHash = hashFn(layerElements[1], layerElements[0])
@ -217,12 +217,12 @@ export class BaseTree {
i++ // skip next idx i++ // skip next idx
layerProofs.push(layerHash) layerProofs.push(layerHash)
} else { } else {
if (elIdx % 2 === 0) { if (elIndex % 2 === 0) {
layerHash = hashFn(layerElements[0], proofElements[0]) layerHash = hashFn(layerElements[0], proofElements[0])
} else { } else {
layerHash = hashFn(proofElements[0], layerElements[0]) layerHash = hashFn(proofElements[0], layerElements[0])
} }
layerElements.shift() layerElements.shift() // remove 1st element
layerProofs.push(layerHash) layerProofs.push(layerHash)
if (proofElements.shift() === undefined) { if (proofElements.shift() === undefined) {
break break