refactor: simplify some code in MsgV3

This commit is contained in:
Andre Staltz 2023-11-13 20:44:20 +02:00
parent accc41a68c
commit 9223402335
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
1 changed files with 7 additions and 9 deletions

View File

@ -151,15 +151,13 @@ function create(opts) {
const accountTips = opts.accountTips ? opts.accountTips.sort() : null const accountTips = opts.accountTips ? opts.accountTips.sort() : null
const tangles = /** @type {Msg['metadata']['tangles']} */ ({}) const tangles = /** @type {Msg['metadata']['tangles']} */ ({})
if (opts.tangles) { for (const rootID in opts.tangles) {
for (const rootID in opts.tangles) { if ((err = validateMsgID(rootID))) throw err
if ((err = validateMsgID(rootID))) throw err const tangle = opts.tangles[rootID]
const tangle = opts.tangles[rootID] const depth = tangle.maxDepth + 1
const depth = tangle.maxDepth + 1 const lipmaaSet = tangle.getLipmaaSet(depth)
const lipmaaSet = tangle.getLipmaaSet(depth) const prev = [...union(lipmaaSet, tangle.tips)].sort()
const prev = [...union(lipmaaSet, tangle.tips)].sort() tangles[rootID] = { depth, prev }
tangles[rootID] = { depth, prev }
}
} }
/** @type {Msg} */ /** @type {Msg} */