From 7ef3cb8ab895339e0b35fdffa15b47f7d5a942b1 Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Fri, 14 Mar 2025 08:02:42 -0500 Subject: [PATCH] Fix an iterator error that would cause an infinite loop --- src/lib/data_structures/publication_tree.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/data_structures/publication_tree.ts b/src/lib/data_structures/publication_tree.ts index 0b16045..4306b1e 100644 --- a/src/lib/data_structures/publication_tree.ts +++ b/src/lib/data_structures/publication_tree.ts @@ -223,7 +223,7 @@ export class PublicationTree implements AsyncIterable { } async next(): Promise> { - while (this.#cursor.target?.type !== PublicationTreeNodeType.Leaf) { + do { if (await this.#cursor.tryMoveToFirstChild()) { continue; } @@ -232,14 +232,14 @@ export class PublicationTree implements AsyncIterable { continue; } - if (await this.#cursor.tryMoveToParent()) { + if (this.#cursor.tryMoveToParent()) { continue; } if (this.#cursor.target?.type === PublicationTreeNodeType.Root) { return { done: true, value: null }; } - } + } while (this.#cursor.target?.type !== PublicationTreeNodeType.Leaf); const event = await this.getEvent(this.#cursor.target!.address); return { done: false, value: event! };