Compare commits
2 Commits
bulk-inser
...
123
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c83a4a4dc0 | ||
|
|
2b6b5c481d |
@@ -22,13 +22,13 @@ class MerkleTree {
|
||||
* @param {hashFunction} [options.hashFunction] Function used to hash 2 leaves
|
||||
* @param [options.zeroElement] Value for non-existent leaves
|
||||
*/
|
||||
constructor(levels, elements = [], { hashFunction, zeroElement = DEFAULT_ZERO } = {}) {
|
||||
constructor(levels, elements = [], { hashFunction = defaultHash, zeroElement = DEFAULT_ZERO } = {}) {
|
||||
this.levels = levels
|
||||
this.capacity = 2 ** levels
|
||||
if (elements.length > this.capacity) {
|
||||
throw new Error('Tree is full')
|
||||
}
|
||||
this._hash = hashFunction || defaultHash
|
||||
this._hash = hashFunction
|
||||
this.zeroElement = zeroElement
|
||||
this._zeros = []
|
||||
this._zeros[0] = zeroElement
|
||||
|
||||
Reference in New Issue
Block a user