首页 > 其他 > 详细

proto school tutorial: blog: lesson 1

时间:2020-02-14 12:08:07      阅读:58      评论:0      收藏:0      [点我收藏+]

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

proto school tutorial: blog: lesson 1

原文:https://www.cnblogs.com/paulkg12/p/12306523.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!