Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
each(trieNode.getChildren(), (childData, next) => {
let key = nibbleToPath(childData[0])
let value = childData[1]
if (EthTrieNode.isRawNode(value)) {
// inline child root
let childNode = new EthTrieNode(value)
paths.push({
path: key,
value: childNode
})
// inline child non-leaf subpaths
exports.treeFromObject(multicodec, childNode, options, (err, subtree) => {
if (err) return next(err)
subtree.forEach((path) => {
path.path = key + '/' + path.path
})
paths = paths.concat(subtree)
next()
})
} else {
trieNode.getChildren().forEach(([nibble, value]) => {
let valueToAdd
if (EthTrieNode.isRawNode(value)) {
// inline child root
const childNode = new EthTrieNode(value)
if (childNode.type === 'leaf') {
// Make sure the object is nested correctly
nibble.push(...childNode.getKey())
valueToAdd = getLeafValue(childNode, leafResolver)
} else {
valueToAdd = childNode
}
} else {
// other nodes link by hash
valueToAdd = cidFromHash(codec, value)
}
addNibbleToObject(finalNode, nibble, valueToAdd)
})