mirror of
https://github.com/tornadocash/tornado-core.git
synced 2024-12-25 22:39:22 -05:00
fix a bug
This commit is contained in:
parent
13b9a948dc
commit
754172a5a4
@ -26,9 +26,9 @@ class MerkleTree {
|
|||||||
this.storage.put(MerkleTree.index_to_key(prefix, level, i), element)
|
this.storage.put(MerkleTree.index_to_key(prefix, level, i), element)
|
||||||
})
|
})
|
||||||
level++
|
level++
|
||||||
let numberOfElementInRow = Math.ceil(defaultElements.length / 2)
|
let numberOfElementsInLevel = Math.ceil(defaultElements.length / 2)
|
||||||
for (level; level <= this.n_levels; level++) {
|
for (level; level <= this.n_levels; level++) {
|
||||||
for(let i = 0; i < numberOfElementInRow; i++) {
|
for(let i = 0; i < numberOfElementsInLevel; i++) {
|
||||||
const leftKey = MerkleTree.index_to_key(prefix, level - 1, 2 * i)
|
const leftKey = MerkleTree.index_to_key(prefix, level - 1, 2 * i)
|
||||||
const rightKey = MerkleTree.index_to_key(prefix, level - 1, 2 * i + 1)
|
const rightKey = MerkleTree.index_to_key(prefix, level - 1, 2 * i + 1)
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ class MerkleTree {
|
|||||||
const subRoot = this.hasher.hash(null, left, right)
|
const subRoot = this.hasher.hash(null, left, right)
|
||||||
this.storage.put(MerkleTree.index_to_key(prefix, level, i), subRoot)
|
this.storage.put(MerkleTree.index_to_key(prefix, level, i), subRoot)
|
||||||
}
|
}
|
||||||
numberOfElementInRow = Math.max(Math.ceil(numberOfElementInRow / 2), 1)
|
numberOfElementsInLevel = Math.ceil(numberOfElementsInLevel / 2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user