fix tree slices order
This commit is contained in:
parent
e9f123a8b2
commit
6df03ab139
@ -204,12 +204,12 @@ export default class MerkleTree {
|
|||||||
let size = Math.ceil(length / count)
|
let size = Math.ceil(length / count)
|
||||||
size % 2 && size++
|
size % 2 && size++
|
||||||
const slices = []
|
const slices = []
|
||||||
for (let i = length - size - 1; i > -size; i -= size) {
|
for (let i = 0; i < length; i += size) {
|
||||||
const edgeLeft = i >= 0 ? i : 0
|
const edgeLeft = i
|
||||||
const edgeRight = i + size
|
const edgeRight = i + size
|
||||||
slices.push({ edge: this.getTreeEdge(edgeLeft), elements: this.elements.slice(edgeLeft, edgeRight) })
|
slices.push({ edge: this.getTreeEdge(edgeLeft), elements: this.elements.slice(edgeLeft, edgeRight) })
|
||||||
}
|
}
|
||||||
return slices.reverse()
|
return slices
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user