Skip to content

Commit

Permalink
Merge pull request #182 from AmbireTech/deduplicate-in-MerkleTree-opt…
Browse files Browse the repository at this point in the history
…ional

deduplicate-in-MerkleTree-optiona
  • Loading branch information
Ivshti authored Oct 3, 2022
2 parents ef2f88f + 9749cfd commit 3aa40d4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 396 deletions.
4 changes: 2 additions & 2 deletions js/MerkleTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ function getNextLayer(elements) {
}

class MerkleTree {
constructor(_elements) {
constructor(_elements, settings = { deduplicate: true }) {
if (!_elements.every(b => b.length === 32 && Buffer.isBuffer(b))) {
throw new Error('elements must be 32 byte buffers')
}
const e = { elements: deduplicate(_elements) }
const e = { elements: (settings.deduplicate ? deduplicate(_elements) : _elements) }
Object.assign(this, e)
this.elements.sort(Buffer.compare)

Expand Down
Loading

0 comments on commit 3aa40d4

Please sign in to comment.