mirror of
https://github.com/tornadocash/fixed-merkle-tree.git
synced 2025-01-04 02:45:21 +01:00
Renaming variables
This commit is contained in:
parent
eda667cdcd
commit
727be9d333
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user