Skip to content

Commit

Permalink
deduplicate-in-MerkleTree-optiona
Browse files Browse the repository at this point in the history
  • Loading branch information
stojnovsky committed Oct 3, 2022
1 parent ef2f88f commit c85877a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions js/MerkleTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ function getNextLayer(elements) {
}

class MerkleTree {
constructor(_elements) {
constructor(_elements, _settings) {
const settings = _settings || {}
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 === false ? _elements : deduplicate(_elements)) }
Object.assign(this, e)
this.elements.sort(Buffer.compare)

Expand Down

0 comments on commit c85877a

Please sign in to comment.