mirror of
https://github.com/tornadocash/tornado-core.git
synced 2025-05-05 07:44:57 -04:00
merkle tree update - getIndexByElement
This commit is contained in:
parent
b0c896c681
commit
3f3e0534cc
2 changed files with 31 additions and 0 deletions
|
@ -179,6 +179,16 @@ class MerkleTree {
|
|||
current_index = Math.floor(current_index / 2)
|
||||
}
|
||||
}
|
||||
|
||||
getIndexByElement(element) {
|
||||
for(let i = this.totalElements - 1; i >= 0; i--) {
|
||||
const elementFromTree = this.storage.get(MerkleTree.index_to_key(this.prefix, 0, i))
|
||||
if (elementFromTree === element) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = MerkleTree
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue