mirror of
https://github.com/tornadocash/tornado-core.git
synced 2025-05-06 00:05:06 -04:00
move unused tree args to the right and provide defaults
This commit is contained in:
parent
8f687ca146
commit
981325b1ff
5 changed files with 32 additions and 55 deletions
|
@ -1,15 +1,17 @@
|
|||
const jsStorage = require("./Storage");
|
||||
const mimcHasher = require("./MiMC");
|
||||
|
||||
class MerkleTree {
|
||||
|
||||
constructor(prefix, storage, hasher, n_levels, zero_value, defaultElements) {
|
||||
constructor(n_levels, zero_value, defaultElements, prefix, storage, hasher) {
|
||||
this.prefix = prefix;
|
||||
this.storage = storage;
|
||||
this.hasher = hasher;
|
||||
this.storage = storage || new jsStorage();
|
||||
this.hasher = hasher || new mimcHasher();
|
||||
this.n_levels = n_levels;
|
||||
this.zero_values = [];
|
||||
this.totalElements = 0;
|
||||
|
||||
let current_zero_value = zero_value;
|
||||
let current_zero_value = zero_value || 0;
|
||||
this.zero_values.push(current_zero_value);
|
||||
for (let i = 0; i < n_levels; i++) {
|
||||
current_zero_value = this.hasher.hash(i, current_zero_value, current_zero_value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue