This commit is contained in:
Alexey 2021-07-06 13:44:12 +03:00
parent 4f6ff9b777
commit 823545596e
2 changed files with 14 additions and 9 deletions

6
.prettierrc Normal file
View File

@ -0,0 +1,6 @@
{
"semi": false,
"arrowParens": "always",
"singleQuote": true,
"printWidth": 110
}

View File

@ -47,9 +47,9 @@ class MerkleTree {
for (let i = 0; i < Math.ceil(this._layers[level - 1].length / 2); i++) { for (let i = 0; i < Math.ceil(this._layers[level - 1].length / 2); i++) {
this._layers[level][i] = this._hash( this._layers[level][i] = this._hash(
this._layers[level - 1][i * 2], this._layers[level - 1][i * 2],
i * 2 + 1 < this._layers[level - 1].length ? i * 2 + 1 < this._layers[level - 1].length
this._layers[level - 1][i * 2 + 1] : ? this._layers[level - 1][i * 2 + 1]
this._zeros[level - 1], : this._zeros[level - 1]
) )
} }
} }
@ -100,9 +100,9 @@ class MerkleTree {
index >>= 1 index >>= 1
this._layers[level][index] = this._hash( this._layers[level][index] = this._hash(
this._layers[level - 1][index * 2], this._layers[level - 1][index * 2],
index * 2 + 1 < this._layers[level - 1].length ? index * 2 + 1 < this._layers[level - 1].length
this._layers[level - 1][index * 2 + 1] : ? this._layers[level - 1][index * 2 + 1]
this._zeros[level - 1], : this._zeros[level - 1]
) )
} }
} }
@ -120,9 +120,8 @@ class MerkleTree {
const pathIndices = [] const pathIndices = []
for (let level = 0; level < this.levels; level++) { for (let level = 0; level < this.levels; level++) {
pathIndices[level] = index % 2 pathIndices[level] = index % 2
pathElements[level] = (index ^ 1) < this._layers[level].length ? pathElements[level] =
this._layers[level][index ^ 1] : (index ^ 1) < this._layers[level].length ? this._layers[level][index ^ 1] : this._zeros[level]
this._zeros[level]
index >>= 1 index >>= 1
} }
return { return {