merkle tree lib

This commit is contained in:
Alexey 2019-07-11 13:38:22 +03:00
parent c0e27ffafc
commit 65fd0202c5
4 changed files with 377 additions and 8 deletions

36
lib/Storage.js Normal file
View file

@ -0,0 +1,36 @@
class JsStorage {
constructor() {
this.db = {};
}
get(key) {
return this.db[key];
}
get_or_element(key, defaultElement) {
const element = this.db[key];
if (element === undefined) {
return defaultElement;
} else {
return element
}
}
put(key, value) {
this.db[key] = value;
}
del(key) {
delete this.db[key];
}
put_batch(key_values) {
key_values.forEach(element => {
this.db[element.key] = element.value;
});
}
}
module.exports = JsStorage;