treat cases where getTangle() is null

This commit is contained in:
Andre Staltz 2024-01-30 17:35:48 +02:00
parent 6707df0ee4
commit 40d1e8cb21
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
1 changed files with 3 additions and 2 deletions

View File

@ -254,6 +254,7 @@ function initDict(peer, config) {
// tangle suffix built as a slice from the fieldRoots // tangle suffix built as a slice from the fieldRoots
const mootID = MsgV4.getMootID(loadedAccountID, fromSubdomain(subdomain)) const mootID = MsgV4.getMootID(loadedAccountID, fromSubdomain(subdomain))
const tangle = peer.db.getTangle(mootID) const tangle = peer.db.getTangle(mootID)
if (!tangle) return 0
const maxDepth = tangle.maxDepth const maxDepth = tangle.maxDepth
const fieldRoots = _getFieldRoots(subdomain) const fieldRoots = _getFieldRoots(subdomain)
let minDepth = Infinity let minDepth = Infinity
@ -352,7 +353,7 @@ function initDict(peer, config) {
const tangle = peer.db.getTangle(tangleID) const tangle = peer.db.getTangle(tangleID)
// prettier-ignore // prettier-ignore
if (!tangle || tangle.size === 0) return 0 if (!tangle) return 0
// prettier-ignore // prettier-ignore
if (!MsgV4.isMoot(tangle.root)) throw new Error(`Tangle "${tangleID}" is not a moot`) if (!MsgV4.isMoot(tangle.root)) throw new Error(`Tangle "${tangleID}" is not a moot`)
const domain = tangle.root.metadata.domain const domain = tangle.root.metadata.domain
@ -400,7 +401,7 @@ function initDict(peer, config) {
const domain = fromSubdomain(subdomain) const domain = fromSubdomain(subdomain)
const mootID = MsgV4.getMootID(id, domain) const mootID = MsgV4.getMootID(id, domain)
const tangle = peer.db.getTangle(mootID) const tangle = peer.db.getTangle(mootID)
if (!tangle || tangle.size === 0) { if (!tangle) {
if (id === loadedAccountID) return {} if (id === loadedAccountID) return {}
else return null else return null
} }