mirror of https://codeberg.org/pzp/pzp-set.git
treat cases where getTangle() is null
This commit is contained in:
parent
05ffc906fd
commit
eeeed1dfb7
|
@ -195,7 +195,7 @@ function initSet(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) return new Set()
|
if (!tangle) return new Set()
|
||||||
const msgIDs = tangle.topoSort()
|
const msgIDs = tangle.topoSort()
|
||||||
const set = new Set()
|
const set = new Set()
|
||||||
for (const msgID of msgIDs) {
|
for (const msgID of msgIDs) {
|
||||||
|
@ -285,6 +285,7 @@ function initSet(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 currentItemRoots = itemRoots.getAll(subdomain)
|
const currentItemRoots = itemRoots.getAll(subdomain)
|
||||||
let minDepth = Infinity
|
let minDepth = Infinity
|
||||||
|
@ -468,7 +469,7 @@ function initSet(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
|
||||||
|
|
Loading…
Reference in New Issue