什么是 multicodec 以及它与 multihash 有何关系?

What is multicodec and how it is related to multihash?

我没有这方面的背景知识。

为了更好地理解它们,我阅读了:


据我了解,multihash 是用于散列(一种方式)值的算法。所以这意味着,我们无法返回(我们无法将哈希解码为值)。

问题

  1. 我不明白,简单来说,什么是 multicodec 以及它是否与将哈希解码为值有关(这毫无意义)。
  2. multicodec前缀的动机是什么?
  1. multicodec与解码散列指向的值有关,如果这样更容易理解的话。别担心,不会发生神奇的哈希解码 ;)。请记住,我们正在制作 CID,我们可以使用 CID 来查找内容。然而,我们遇到了“我们如何解码刚刚检索到的数据?”的问题,multicodec 为我们解决了这个问题。阅读 From Data to Data Structures 可能有助于消除一些困惑。

  2. multicodec 前缀允许 IPFS 发展以支持实际放入 IPFS 的数据的新的和不同的编码。这里指的是IPLD, and you can actually find the answer you're looking for under Links (with information about the codecs under Codecs):

For links we use a CID. A CID is an extension of multihash, in fact a multihash is part of a CID. We simply add a codec to a multihash that tells us what format the data is in (JSON, CBOR, Bitcoin, Ethereum, etc). This way, we can actually link between data in different formats and any link to data anyone ever gives us can be decoded so that it can become more than just a series of bytes.

CID is a standard that anyone can implement, even people that have no other interest in IPLD beyond the need for hash links to different data types can use it.