From 92234023353f72674064f6735e4220a5fe6abf42 Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Mon, 13 Nov 2023 20:44:20 +0200 Subject: [PATCH] refactor: simplify some code in MsgV3 --- lib/msg-v3/index.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/msg-v3/index.js b/lib/msg-v3/index.js index 8faeb65..77510d9 100644 --- a/lib/msg-v3/index.js +++ b/lib/msg-v3/index.js @@ -151,15 +151,13 @@ function create(opts) { const accountTips = opts.accountTips ? opts.accountTips.sort() : null const tangles = /** @type {Msg['metadata']['tangles']} */ ({}) - if (opts.tangles) { - for (const rootID in opts.tangles) { - if ((err = validateMsgID(rootID))) throw err - const tangle = opts.tangles[rootID] - const depth = tangle.maxDepth + 1 - const lipmaaSet = tangle.getLipmaaSet(depth) - const prev = [...union(lipmaaSet, tangle.tips)].sort() - tangles[rootID] = { depth, prev } - } + for (const rootID in opts.tangles) { + if ((err = validateMsgID(rootID))) throw err + const tangle = opts.tangles[rootID] + const depth = tangle.maxDepth + 1 + const lipmaaSet = tangle.getLipmaaSet(depth) + const prev = [...union(lipmaaSet, tangle.tips)].sort() + tangles[rootID] = { depth, prev } } /** @type {Msg} */