fix: bulk insert empty elements

This commit is contained in:
Danil Kovtonyuk 2022-02-17 01:05:45 +10:00
parent d5816e7cf4
commit e3c54ea818
No known key found for this signature in database
GPG Key ID: E72A919BF08C3746
2 changed files with 5 additions and 1 deletions

@ -1,6 +1,6 @@
{
"name": "fixed-merkle-tree",
"version": "0.6.0",
"version": "0.6.1",
"description": "Fixed depth merkle tree implementation with sequential inserts",
"repository": "https://github.com/tornadocash/fixed-merkle-tree.git",
"main": "src/merkleTree.js",

@ -78,6 +78,10 @@ class MerkleTree {
* @param {Array} elements Elements to insert
*/
bulkInsert(elements) {
if (!elements.length) {
return
}
if (this._layers[0].length + elements.length > this.capacity) {
throw new Error('Tree is full')
}