diff --git a/lib/algorithm.js b/lib/algorithm.js index f64758b..62fc7c6 100644 --- a/lib/algorithm.js +++ b/lib/algorithm.js @@ -235,6 +235,7 @@ class Algorithm { const accountMsgs = [] for (const [accountID, tips] of accountTips) { const accountTangle = this.#peer.db.getTangle(accountID) + if (!accountTangle) continue accountMsgs.push(...accountTangle.slice([], [...tips])) } return accountMsgs @@ -275,6 +276,7 @@ class Algorithm { msgs.push(rootMsg) } const tangle = this.#peer.db.getTangle(rootID) + if (!tangle) return msgs for (const msg of tangle.slice()) { const depth = msg.metadata.tangles[rootID]?.depth ?? 0 if (depth >= minDepth && depth <= maxDepth) { @@ -300,6 +302,7 @@ class Algorithm { typeof m === 'string' ? m : MsgV4.getMsgID(m) ) const tangle = this.#peer.db.getTangle(rootID) + if (!tangle) return [] return tangle.slice(msgIDs, []) } @@ -312,6 +315,7 @@ class Algorithm { */ async pruneNewest(rootID, count) { const tangle = this.#peer.db.getTangle(rootID) + if (!tangle) return const sorted = tangle.topoSort() if (sorted.length <= count) return const msgID = sorted[sorted.length - count] // New "oldest dataful msg"