Skip to content

Commit

Permalink
Merge pull request #44 from iden3/fix/insert-after-delete
Browse files Browse the repository at this point in the history
insert after delete
  • Loading branch information
ilya-korotya authored Apr 30, 2024
2 parents 651e764 + 6d4a02e commit 9ffaf74
Show file tree
Hide file tree
Showing 2 changed files with 313 additions and 43 deletions.
3 changes: 2 additions & 1 deletion src/lib/merkletree/merkletree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ export class Merkletree {
await this.#db.setRoot(this.#root);
}

const nearestSibling = await this.#db.get(kHash.bytes);
const nearestSibling = await this.#db.get(toUpload.bytes);
if (nearestSibling?.type === NODE_TYPE_MIDDLE) {
let newNode: Node;
if (path[siblings.length - 1]) {
Expand All @@ -418,6 +418,7 @@ export class Merkletree {
);
this.#root = newRootKey;
await this.#db.setRoot(this.#root);
return;
}

for (let i = siblings.length - 2; i >= 0; i -= 1) {
Expand Down
Loading

0 comments on commit 9ffaf74

Please sign in to comment.