simpler serialization

This commit is contained in:
poma 2020-09-25 17:16:01 +03:00
parent 96e254a46b
commit 4f6ff9b777
No known key found for this signature in database
GPG Key ID: BA20CB01FE165657
2 changed files with 3 additions and 3 deletions

View File

@ -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": {

View File

@ -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
}
}