How to use the merkle-patricia-tree/trieNode.isRawNode function in merkle-patricia-tree

To help you get started, we’ve selected a few merkle-patricia-tree examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipld / js-ipld-ethereum / util / base-trie / resolver.js View on Github external
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 {
github ipld / js-ipld-ethereum / util / createTrieResolver.js View on Github external
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)
  })