mirror of
https://github.com/tornadocash/fixed-merkle-tree.git
synced 2024-11-25 19:31:36 +01:00
simpler serialization
This commit is contained in:
parent
96e254a46b
commit
4f6ff9b777
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "fixed-merkle-tree",
|
"name": "fixed-merkle-tree",
|
||||||
"version": "0.4.0",
|
"version": "0.5.0",
|
||||||
"description": "Fixed depth merkle tree implementation with sequential inserts",
|
"description": "Fixed depth merkle tree implementation with sequential inserts",
|
||||||
"main": "src/merkleTree.js",
|
"main": "src/merkleTree.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -161,8 +161,6 @@ class MerkleTree {
|
|||||||
serialize() {
|
serialize() {
|
||||||
return {
|
return {
|
||||||
levels: this.levels,
|
levels: this.levels,
|
||||||
capacity: this.capacity,
|
|
||||||
zeroElement: this.zeroElement,
|
|
||||||
_zeros: this._zeros,
|
_zeros: this._zeros,
|
||||||
_layers: this._layers,
|
_layers: this._layers,
|
||||||
}
|
}
|
||||||
@ -180,6 +178,8 @@ class MerkleTree {
|
|||||||
static deserialize(data, hashFunction) {
|
static deserialize(data, hashFunction) {
|
||||||
const instance = Object.assign(Object.create(this.prototype), data)
|
const instance = Object.assign(Object.create(this.prototype), data)
|
||||||
instance._hash = hashFunction || defaultHash
|
instance._hash = hashFunction || defaultHash
|
||||||
|
instance.capacity = 1 << instance.levels
|
||||||
|
instance.zeroElement = instance._zeros[0]
|
||||||
return instance
|
return instance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user