mirror of https://codeberg.org/pzp/pzp-sync.git
treat cases where getTangle() is null
This commit is contained in:
parent
2a4f39a832
commit
0bc100557e
|
@ -235,6 +235,7 @@ class Algorithm {
|
||||||
const accountMsgs = []
|
const accountMsgs = []
|
||||||
for (const [accountID, tips] of accountTips) {
|
for (const [accountID, tips] of accountTips) {
|
||||||
const accountTangle = this.#peer.db.getTangle(accountID)
|
const accountTangle = this.#peer.db.getTangle(accountID)
|
||||||
|
if (!accountTangle) continue
|
||||||
accountMsgs.push(...accountTangle.slice([], [...tips]))
|
accountMsgs.push(...accountTangle.slice([], [...tips]))
|
||||||
}
|
}
|
||||||
return accountMsgs
|
return accountMsgs
|
||||||
|
@ -275,6 +276,7 @@ class Algorithm {
|
||||||
msgs.push(rootMsg)
|
msgs.push(rootMsg)
|
||||||
}
|
}
|
||||||
const tangle = this.#peer.db.getTangle(rootID)
|
const tangle = this.#peer.db.getTangle(rootID)
|
||||||
|
if (!tangle) return msgs
|
||||||
for (const msg of tangle.slice()) {
|
for (const msg of tangle.slice()) {
|
||||||
const depth = msg.metadata.tangles[rootID]?.depth ?? 0
|
const depth = msg.metadata.tangles[rootID]?.depth ?? 0
|
||||||
if (depth >= minDepth && depth <= maxDepth) {
|
if (depth >= minDepth && depth <= maxDepth) {
|
||||||
|
@ -300,6 +302,7 @@ class Algorithm {
|
||||||
typeof m === 'string' ? m : MsgV4.getMsgID(m)
|
typeof m === 'string' ? m : MsgV4.getMsgID(m)
|
||||||
)
|
)
|
||||||
const tangle = this.#peer.db.getTangle(rootID)
|
const tangle = this.#peer.db.getTangle(rootID)
|
||||||
|
if (!tangle) return []
|
||||||
return tangle.slice(msgIDs, [])
|
return tangle.slice(msgIDs, [])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,6 +315,7 @@ class Algorithm {
|
||||||
*/
|
*/
|
||||||
async pruneNewest(rootID, count) {
|
async pruneNewest(rootID, count) {
|
||||||
const tangle = this.#peer.db.getTangle(rootID)
|
const tangle = this.#peer.db.getTangle(rootID)
|
||||||
|
if (!tangle) return
|
||||||
const sorted = tangle.topoSort()
|
const sorted = tangle.topoSort()
|
||||||
if (sorted.length <= count) return
|
if (sorted.length <= count) return
|
||||||
const msgID = sorted[sorted.length - count] // New "oldest dataful msg"
|
const msgID = sorted[sorted.length - count] // New "oldest dataful msg"
|
||||||
|
|
Loading…
Reference in New Issue