proto school tutorial: blog: lesson 1

https://proto.school/#/blog/01

我们现在希望:把一个post 和他的作者联系起来。

  • 从之前的教程here中,你可以知道, 一个cid 就是代表一个link

比如:

{
  linkToAwesomeNode: awesomeCid
  //字段: cid
}

总结就是: 当我们给一个字段赋值一个cid的时候,这个字段其实按照惯例,称为:named link

如下所示:(我们新加了 tt1 and tt2 , they are so called named link)

/* globals ipfs */

const run = async () => {
  const natCid = await ipfs.dag.put({ author: "Nat" })
  const samCid = await ipfs.dag.put({ author: "Sam" })

  const treePostCid = await ipfs.dag.put({
    content: "trees",
    author: samCid//tt1
  })
  const computerPostCid = await ipfs.dag.put({
    content: "computers",
    author: natCid//tt2
  })

  return [treePostCid, computerPostCid]
}

return run

猜你喜欢

转载自www.cnblogs.com/paulkg12/p/12306523.html
今日推荐