Skip to content

Commit

Permalink
Merge pull request #28 from iden3/fix/indexed-db-one-db
Browse files Browse the repository at this point in the history
add database as optional name
  • Loading branch information
vmidyllic authored Jul 7, 2023
2 parents 4c6a97c + 53288aa commit 8af5ff6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iden3/js-merkletree",
"version": "1.0.0-beta.4",
"version": "1.0.0-beta.5",
"description": "javascript sparse merkle tree library",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
7 changes: 5 additions & 2 deletions src/lib/db/indexedDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ export class IndexedDBStorage implements ITreeStorage {

#currentRoot: Hash;

constructor(private readonly _prefix: Bytes) {
constructor(private readonly _prefix: Bytes, databaseName?: string) {
this.#currentRoot = ZERO_HASH;
this._prefixHash = bytes2Hex(_prefix);
this._store = createStore(`${IndexedDBStorage.storageName}-db`, IndexedDBStorage.storageName);
this._store = createStore(
`${databaseName ?? IndexedDBStorage.storageName}-db`,
IndexedDBStorage.storageName
);
}

async get(k: Bytes): Promise<Node | undefined> {
Expand Down

0 comments on commit 8af5ff6

Please sign in to comment.