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 c85877a commit 9749cfd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 397 deletions.
5 changes: 2 additions & 3 deletions js/MerkleTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ function getNextLayer(elements) {
}

class MerkleTree {
constructor(_elements, _settings) {
const settings = _settings || {}
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: (settings.deduplicate === false ? _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 9749cfd

Please sign in to comment.