mirror of https://codeberg.org/pzp/pzp-dict.git
add a try catch, plus minor renaming
This commit is contained in:
parent
cf207f9553
commit
2f885fd807
28
lib/index.js
28
lib/index.js
|
@ -183,13 +183,13 @@ module.exports = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {string} rootID
|
* @param {string} mootID
|
||||||
* @param {Msg} root
|
* @param {Msg} moot
|
||||||
*/
|
*/
|
||||||
function learnRecordRoot(rootID, root) {
|
function learnRecordMoot(mootID, moot) {
|
||||||
const subdomain = toSubdomain(root.metadata.domain)
|
const subdomain = toSubdomain(moot.metadata.domain)
|
||||||
const tangle = tangles.get(subdomain) ?? new MsgV3.Tangle(rootID)
|
const tangle = tangles.get(subdomain) ?? new MsgV3.Tangle(mootID)
|
||||||
tangle.add(rootID, root)
|
tangle.add(mootID, moot)
|
||||||
tangles.set(subdomain, tangle)
|
tangles.set(subdomain, tangle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,9 +200,9 @@ module.exports = {
|
||||||
*/
|
*/
|
||||||
function learnRecordUpdate(msgID, msg) {
|
function learnRecordUpdate(msgID, msg) {
|
||||||
const { account, domain } = msg.metadata
|
const { account, domain } = msg.metadata
|
||||||
const rootID = MsgV3.getMootID(account, domain)
|
const mootID = MsgV3.getMootID(account, domain)
|
||||||
const subdomain = toSubdomain(domain)
|
const subdomain = toSubdomain(domain)
|
||||||
const tangle = tangles.get(subdomain) ?? new MsgV3.Tangle(rootID)
|
const tangle = tangles.get(subdomain) ?? new MsgV3.Tangle(mootID)
|
||||||
tangle.add(msgID, msg)
|
tangle.add(msgID, msg)
|
||||||
tangles.set(subdomain, tangle)
|
tangles.set(subdomain, tangle)
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ module.exports = {
|
||||||
function maybeLearnAboutRecord(msgID, msg) {
|
function maybeLearnAboutRecord(msgID, msg) {
|
||||||
if (msg.metadata.account !== accountID) return
|
if (msg.metadata.account !== accountID) return
|
||||||
if (isValidRecordMoot(msg)) {
|
if (isValidRecordMoot(msg)) {
|
||||||
learnRecordRoot(msgID, msg)
|
learnRecordMoot(msgID, msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (isValidRecordMsg(msg)) {
|
if (isValidRecordMsg(msg)) {
|
||||||
|
@ -317,9 +317,13 @@ module.exports = {
|
||||||
}
|
}
|
||||||
cancelOnRecordAdded = peer.db.onRecordAdded(
|
cancelOnRecordAdded = peer.db.onRecordAdded(
|
||||||
(/** @type {RecPresent} */ rec) => {
|
(/** @type {RecPresent} */ rec) => {
|
||||||
if (!rec.msg) return
|
try {
|
||||||
maybeLearnAboutRecord(rec.id, rec.msg)
|
maybeLearnAboutRecord(rec.id, rec.msg)
|
||||||
})
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
resolve()
|
resolve()
|
||||||
cb()
|
cb()
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue