From eeeed1dfb74f3c3a75263edb8f957880b00dffb5 Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Tue, 30 Jan 2024 17:41:54 +0200 Subject: [PATCH] treat cases where getTangle() is null --- lib/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 3927657..70a1eac 100644 --- a/lib/index.js +++ b/lib/index.js @@ -195,7 +195,7 @@ function initSet(peer, config) { const domain = fromSubdomain(subdomain) const mootID = MsgV4.getMootID(id, domain) const tangle = peer.db.getTangle(mootID) - if (!tangle || tangle.size === 0) return new Set() + if (!tangle) return new Set() const msgIDs = tangle.topoSort() const set = new Set() for (const msgID of msgIDs) { @@ -285,6 +285,7 @@ function initSet(peer, config) { // tangle suffix built as a slice from the fieldRoots const mootID = MsgV4.getMootID(loadedAccountID, fromSubdomain(subdomain)) const tangle = peer.db.getTangle(mootID) + if (!tangle) return 0 const maxDepth = tangle.maxDepth const currentItemRoots = itemRoots.getAll(subdomain) let minDepth = Infinity @@ -468,7 +469,7 @@ function initSet(peer, config) { const tangle = peer.db.getTangle(tangleID) // prettier-ignore - if (!tangle || tangle.size === 0) return 0 + if (!tangle) return 0 // prettier-ignore if (!MsgV4.isMoot(tangle.root)) throw new Error(`Tangle "${tangleID}" is not a moot`) const domain = tangle.root.metadata.domain