fix tree slices order

This commit is contained in:
smart_ex 2022-03-11 11:38:51 +10:00
parent e9f123a8b2
commit 6df03ab139
1 changed files with 3 additions and 3 deletions

View File

@ -204,12 +204,12 @@ export default class MerkleTree {
let size = Math.ceil(length / count)
size % 2 && size++
const slices = []
for (let i = length - size - 1; i > -size; i -= size) {
const edgeLeft = i >= 0 ? i : 0
for (let i = 0; i < length; i += size) {
const edgeLeft = i
const edgeRight = i + size
slices.push({ edge: this.getTreeEdge(edgeLeft), elements: this.elements.slice(edgeLeft, edgeRight) })
}
return slices.reverse()
return slices
}
/**