mirror of
https://github.com/tornadocash/tornado-core.git
synced 2025-05-03 14:55:17 -04:00
merkle tree lib
This commit is contained in:
parent
c0e27ffafc
commit
65fd0202c5
4 changed files with 377 additions and 8 deletions
36
lib/Storage.js
Normal file
36
lib/Storage.js
Normal 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;
|
Loading…
Add table
Add a link
Reference in a new issue