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
1 changed files with 11 additions and 11 deletions

View File

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