From 4f6ff9b77708479a638a13a91f43675035d16d75 Mon Sep 17 00:00:00 2001 From: poma Date: Fri, 25 Sep 2020 17:16:01 +0300 Subject: [PATCH] simpler serialization --- package.json | 2 +- src/merkleTree.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index bc6065a..f060fb8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fixed-merkle-tree", - "version": "0.4.0", + "version": "0.5.0", "description": "Fixed depth merkle tree implementation with sequential inserts", "main": "src/merkleTree.js", "scripts": { diff --git a/src/merkleTree.js b/src/merkleTree.js index 4fc6b92..72612ea 100644 --- a/src/merkleTree.js +++ b/src/merkleTree.js @@ -161,8 +161,6 @@ class MerkleTree { serialize() { return { levels: this.levels, - capacity: this.capacity, - zeroElement: this.zeroElement, _zeros: this._zeros, _layers: this._layers, } @@ -180,6 +178,8 @@ class MerkleTree { static deserialize(data, hashFunction) { const instance = Object.assign(Object.create(this.prototype), data) instance._hash = hashFunction || defaultHash + instance.capacity = 1 << instance.levels + instance.zeroElement = instance._zeros[0] return instance } }