return cids.toBaseEncodedString();
}
//Read a blog
async function readBlog(postCID){
ipfs.dag.get(postCID,(err,?result)=>{
if (err) {
console.error(‘Error while reading post: ‘ + err)
} else {
console.log(“Post Detailsn”,?result);
return result;
}
});
}
function startPublication(){
addNewAuthor(“vasa”).then((newAuthor)=>{
createBlog(newAuthor,”my first post”,?[“ipfs”,”ipld”,”vasa”,”towardsblockchain”]).then((postCID)=>{
readBlog(postCID);
})
});
}
startPublication();
在运行此代码时,它将首先通过addNewAuthor来创建一个作者,该作者将返回作者的CID。然后将此CID传递给createBlog函数,然后该函数返回postCID。readBlog函数将使用此postCID来获取帖子的详细信息。
你还可以使用IPLD来创建更复杂的应用程序…
好的,这部分就讲到这里。如果你有任何问题,可以在评论中提出。
我希望你可以从这篇文章中学到很多东西。在下一篇文章中,我们将深入探讨分布式Web的命名系统IPNS。敬请期待…
感谢protoschool对于DAGs的出色解读。
感谢你的阅读。
原文作者:vasa
原文链接:https://hackernoon.com/understanding-ipfs-in-depth-1-5-a-beginner-to-advanced-guide-e937675a8c8a
翻译:星际大陆海外团队
本文采摘于网络,不代表本站立场,转载联系作者并注明出处:http://www.longfuchaju.com//chuangye/gushi/5012.html