fix minor Tangle class issues

This commit is contained in:
Andre Staltz 2023-10-19 17:06:51 +03:00
parent 75b36e9730
commit b87ca604eb
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
1 changed files with 3 additions and 3 deletions

View File

@ -224,8 +224,7 @@ class Tangle {
get root() { get root() {
if (!this.#rootMsg) { if (!this.#rootMsg) {
console.trace('Tangle is missing root message') throw new Error(`Tangle "${this.#rootID}" is missing root message`)
return null
} }
return this.#rootMsg return this.#rootMsg
} }
@ -298,7 +297,8 @@ class Tangle {
if (msgBID === this.#rootID) return false if (msgBID === this.#rootID) return false
let toCheck = [msgBID] let toCheck = [msgBID]
while (toCheck.length > 0) { while (toCheck.length > 0) {
const prev = this.#prev.get(/** @type {string} */ (toCheck.shift())) const checking = /** @type {string} */ (toCheck.shift())
const prev = this.#prev.get(checking)
if (!prev) continue if (!prev) continue
if (prev.includes(msgAID)) return true if (prev.includes(msgAID)) return true
toCheck.push(...prev) toCheck.push(...prev)