<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Joonas Koivunen on Medium]]></title>
        <description><![CDATA[Stories by Joonas Koivunen on Medium]]></description>
        <link>https://medium.com/@koivunej?source=rss-9bc6d2d7952a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5YgPnFgRg8nDNLRYDhT6jA.png</url>
            <title>Stories by Joonas Koivunen on Medium</title>
            <link>https://medium.com/@koivunej?source=rss-9bc6d2d7952a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 13:41:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@koivunej/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[UnixFS Exporting has landed. What comes next?]]></title>
            <link>https://medium.com/@koivunej/unixfs-exporting-has-landed-what-comes-next-4775cc568838?source=rss-9bc6d2d7952a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4775cc568838</guid>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[ipfs]]></category>
            <category><![CDATA[rust-ipfs]]></category>
            <dc:creator><![CDATA[Joonas Koivunen]]></dc:creator>
            <pubDate>Fri, 26 Jun 2020 17:31:59 GMT</pubDate>
            <atom:updated>2020-07-20T13:56:10.515Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VbKtqp2_qTRHmY9xLwwE1g@2x.png" /></figure><h4>Rust IPFS Append-Only Log #004</h4><p>In our last post, we <a href="https://medium.com/equilibriumco/the-road-to-unixfs-f3cf5222b2ef">introduced UnixFS</a> and our goal to implement reading (aka exporting) as part of <a href="https://github.com/ipfs/devgrants/blob/master/open-grants/ipfs-rust/phase-2/README.md">Phase 2</a> of a devgrant from Protocol Labs. Today, we’re happy to announce that we completed this work and released a new Rust crate called <a href="https://crates.io/ipfs-unixfs">ipfs-unixfs</a>. The crate supports <a href="https://docs.rs/ipfs-unixfs/0.0.1/ipfs_unixfs/walk/">walking</a> and <a href="https://docs.rs/ipfs-unixfs/0.0.1/ipfs_unixfs/dir/fn.resolve.html">resolving path segments</a> in a MerkleDAG forest, as well as exposing two new HTTP API endpoints /cat and /get.</p><p>So, what next?</p><h3>Onward to Phase 3</h3><p>So there are some big-ticket items on deck for Rust IPFS, some of which we will be tackling in via our a <a href="https://github.com/w3f/General-Grants-Program/pull/283">grant from the Web3 Foundation</a>:</p><ul><li>Switching to the Noise protocol as the default transport security protocol</li><li>Content discovery via libp2p-kad integration</li><li>A more efficient blockstore indexed by multihash</li></ul><h4>Noise Protocol</h4><p>As go-ipfs 0.6 was just released with support for Noise for transport security in addition to the default SECIO. We would like to switch to Noise in Rust IPFS. In addition to the inherent benefits, this will finally allow us to publish theipfs and ipfs-http crates. Publishing has been blocked by work needed on aes-ctr for better compatibility with OpenSSL when using go-ipfs and js-ipfs.</p><h4>Content discovery and record publishing via Kademlia / DHT</h4><p>While our focus has been on other features, it’s high time to land support for the Kademlia DHT. Luckily,rust-libp2p has an extensive implementation in the libp2p-kad crate. This includes content discovery or “client DHT” and DHT record publishing or “server DHT”. While the former is fairly straightforward to implement, supporting the latter for local and global networks, as well as its persistence layer, will take some thought.</p><h4>Blocks Indexed by Multihash</h4><p>The IPFS core implementation team recently made a <a href="https://github.com/ipfs/specs/issues/242">decision to name blocks with plain multihashes</a> moving forward. In Rust IPFS, we currently convert all Cids to Cid version 1 internally, but an implementation of a blockstore keyed by multihash would be more efficient. We have already done initial planning on this.</p><p>That’s not all — some other items on our roadmap not detailed here include:</p><ul><li>Persistent pinning support</li><li>Incorporating some of the bitswap fixes included in go-ipfs 0.5</li><li>The /add HTTP endpoint</li></ul><p>Do you have any questions, comments, or suggestions on what we should land next, or how we should do it? Do you want to contribute, help, or otherwise get involved? <a href="https://github.com/rs-ipfs">Join us on GitHub</a>.</p><h3>Equilibrium is a venture studio focused on building core infrastructure for the distributed web.</h3><h3>Interested in joining us? Shoot us a message <a href="https://equilibrium.co/company/">here</a>.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4775cc568838" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Road to UnixFS]]></title>
            <link>https://medium.com/@koivunej/the-road-to-unixfs-f3cf5222b2ef?source=rss-9bc6d2d7952a------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3cf5222b2ef</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[rustlang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ipfs]]></category>
            <dc:creator><![CDATA[Joonas Koivunen]]></dc:creator>
            <pubDate>Mon, 25 May 2020 17:13:53 GMT</pubDate>
            <atom:updated>2020-06-22T12:11:14.053Z</atom:updated>
            <content:encoded><![CDATA[<h4>Rust IPFS: Append-Only Log #002</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VbKtqp2_qTRHmY9xLwwE1g@2x.png" /></figure><p><a href="https://github.com/ipfs/devgrants/pull/47">The second rust-ipfs grant</a> from Protocol Labs has been approved, and work has begun on the UnixFS! 🎉</p><p>The scope of this grant is the read-side of UnixFS, otherwise known as UnixFS exporting. This post covers <em>why</em> we think it’s an important step in rust-ipfs’s roadmap as well as an in-depth introduction to the relevant parts of UnixFS. We then conclude with some tools you can use to further your learning.</p><h3>Our Roadmap</h3><p>Equilibrium’s vision is of a production-quality IPFS which can be used either as a Rust library or via a fully-conforming HTTP API. Though <a href="https://github.com/rs-ipfs/rust-ipfs">rust-ipfs</a> is still a very young project and are still a ways from any production, we have many of the puzzle pieces in place.</p><p>Now, with the help of second grant, we begin implementation of reading / exporting of UnixFS data. In practice this means two new endpoints:</p><ol><li>/cat for raw file content output, and:</li><li>/get for converting UnixFS trees into tar format so that they can be processed further, e.g. written out to disk.</li></ol><p>As of now, rust-ipfs has a git-like flatfs storage for blocks and an in-memory only storage for smaller items, such as pinning information. Compared to the elder go-ipfs, or the younger js-ipfs, our implementation isn’t too divergent.</p><p>While there are projects like sled for a key-value database, we would like to explore different alternatives for a persistence abstraction and end up with one that would best support compatibility with downstream dependencies. By growing our support from existing tests and with the addition of benchmarking, we will have solid measurements available to guide us.</p><p>For the bigger picture, we picked out the UnixFS exporting as it will allow us to benchmark for the system as a whole: downloading UnixFS data over bitswap, and storing the data while walking their links to gather more wantlist blocks.</p><p>All of the above unlocks one more puzzle piece, setting a baseline for further exploration. So, how does it work?</p><h3>UnixFS Exporting</h3><p>Let’s start by refreshing the context of IPFS and how UnixFS fits into the big picture:</p><ul><li>The InterPlanetary File System (IPFS) is a mature project which provides crucial decentralized infrastructure by dealing with blocks of data identified by content-identifier (<a href="https://docs-beta.ipfs.io/concepts/content-addressing/#identifier-formats">CID</a>).</li><li>CIDs are a combination of their contents hash and metadata about the contents.</li><li>A MerkleDAG is a directed acyclic graph built using CIDs as pointers, which brings us to:</li><li>UnixFS, which is a specification for Unix-alike file data in IPFS on top of <a href="https://docs-beta.ipfs.io/concepts/merkle-dag/">MerkleDAG</a>.</li></ul><p>On IPFS all data is naturally forms a directed acyclic graphs, since it’s <em>incredibly difficult</em> to create cyclic graph where two blocks could link to each other, as hashes of both would need contain hashes of the linked block. This comes</p><p>Also note that both dag-pb and UnixFS are being actively developed under a new name, focusing more on the data representation: InterPlanetary Linked Data (IPLD). The already-deployed <a href="https://github.com/ipld/specs/blob/master/block-layer/codecs/dag-cbor.md">dag-cbor</a> and <a href="https://github.com/ipld/specs/blob/master/block-layer/codecs/dag-json.md">dag-json</a> formats still link data blocks using the same CID primitive.</p><h3>Tools used and notation</h3><p>To explore the MerkleDAG or dag-pb forest, we’ll use the following tools. Feel free to install them and follow along:</p><ul><li><a href="https://github.com/ipfs/go-ipfs/releases">go-ipfs 0.5</a></li><li><a href="https://github.com/ipfs/js-ipfs">js-ipfs.0.44.0</a></li><li>protoc from Google’s protobuf-compiler package</li><li>--raw_decode decodes unknown messages into a pretty printed format</li><li>--decode &lt;ITEM&gt; &lt;proto file&gt; decodes given ITEM from input, given the proto file</li><li>sha256sum from GNU coreutils</li></ul><p>Code blocks conventions are as follows:</p><pre>$ dollar-sign prefixed line represents a runnable bash command \<br>    with the escape sign at the end of a line representing \<br>    line continuation.<br>here would be the command output<br>...<br>ellipsis means we have trimmed the output</pre><h3>Structure of an UnixFS encoded data</h3><p>UnixFS is protocol buffers (protobuf) encoded block described in a .proto file. If you are new to protobuf, it is Googles interface description language (<a href="https://en.wikipedia.org/wiki/Interface_description_language">IDL</a>) which has wide support across languages, and nice <a href="https://developers.google.com/protocol-buffers">documentation</a>. There are different versions of the description, UnixFSv1.5 extends UnixFSv1 by the additional metadata message. UnixFSv2 will be based on IPLD.</p><p>Protobuf encoding on the high level is list of (field, value) pairs where:</p><ol><li>field is a combination of identifier for a field defined in a proto file and the length of the value.</li><li>valueis the value itself i.e. any arbitrary data.</li></ol><p>The fields in a proto file describe how value needs to be interpreted. This can be anything from raw bytes, utf-8 strings, to other messages. Fields can also be repeated in the encoding, but need then be specified as repeated. There’s more to it, but that’s all you need to know for now.</p><p>UnixFS Data messages (<a href="https://github.com/ipfs/go-ipfs/blob/b3faaad1310bcc32dc3dd24e1919e9edf51edba8/unixfs/pb/unixfs.proto#L3">unixfs.proto:3</a>) in blocks are encoded as the message inside the field Data of message PBNode (<a href="https://github.com/dvc94ch/rust-ipfs/blob/master/src/ipld/formats/pb/dag_pb.proto#L16">dag-pb.proto:16</a>). Technically the PBNode could have any other kind of data inside it as well, but in practice many other uses have not surfaced. &quot;What is inside of PBNode::Data&quot; seems to have prompted the addition of multicodec into CID version 1, in practice it is assumed that PBNode::Data does contain the UnixFS Data message or cannot be processed, with some exceptions.</p><h3>Example: Single-block file</h3><p>The simplest example of an UnixFS in action is a file with the six-byte contents of foobar.</p><pre>$ # -n suppresses newline<br>$ echo -n foobar | ipfs add<br>added QmdLbcg1LnNqtNwYmYm4vXW6H7DTegdZsxKnPUw4XgVuhM ...</pre><p>Great! Now let’s use cat to make sure we get back the same bytes:</p><pre>$ ipfs cat QmdLbcg1LnNqtNwYmYm4vXW6H7DTegdZsxKnPUw4XgVuhM<br>foobar</pre><p>In CID version 0 the cryptographic SHA-2 256 bit hash of the contents has been encoded in <a href="https://tools.ietf.org/html/draft-msporny-base58-01">base58btc</a>. Perhaps a more readable encoding would be hex or base16 in multicodec terms, which we can get by:</p><pre>$ ipfs cid format -b base16 -f %D \<br>    QmdLbcg1LnNqtNwYmYm4vXW6H7DTegdZsxKnPUw4XgVuhM<br>dedbce4d04de9aa2fa109eb645f5c2c45c2cd3db9715caeae7e5d8870811ebc4</pre><p>Now that we have the hex representation out, we can compare it to the sha256sum output for the 6 bytes:</p><pre>$ echo -n foobar | sha256sum<br>c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2 -</pre><p><strong>Wait, whaaaaat??? Why aren’t the hashes the same?</strong></p><p>Great question. They are different because the <em>block identified with the CID</em> contains the file inside of a UnixFS encoding, which is itself inside an dag-pb encoding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*DLsR9Q8hMsDv0G98DFeMww.png" /><figcaption>Think of it like three of those matryoshka dolls</figcaption></figure><p>To understand better, lets start working on the block itself:</p><pre>$ ipfs block get QmdLbcg1LnNqtNwYmYm4vXW6H7DTegdZsxKnPUw4XgVuhM \<br>    | sha256sum<br>dedbce4d04de9aa2fa109eb645f5c2c45c2cd3db9715caeae7e5d8870811ebc4</pre><p>We can now confirm that the block sha256 hash does indeed match the base16 formatted hash we converted earlier. ipfs block get gives us access to the raw data of a block.</p><p>We can start decoding the matryoshka doll with protoc --decode_raw which works by decoding the input field by field, using heuristics to determine if a length delimited field value could be string, raw bytes or an inner message:</p><pre>$ ipfs block get QmdLbcg1LnNqtNwYmYm4vXW6H7DTegdZsxKnPUw4XgVuhM \<br>    | protoc --decode_raw<br>1 {<br>  1: 2<br>  2: &quot;foobar&quot;<br>  3: 6<br>}</pre><p>From this output we could go ahead and at the outer level recognize that field identifier 1 is for PBNode::Data field, which now contains an inner protobuf message. The inner protobuf message fits the message Data defined in the unixfs.proto and it’s we can see values for it’s fields Type, Data and filesize. For more readable experience we could use protoc with a <a href="https://gist.github.com/koivunej/e3701c3d9fe602edbaeee1813376d5b7">custom combined proto descriptor</a> (for exploratory use only) to get:</p><pre>$ ipfs block get QmdLbcg1LnNqtNwYmYm4vXW6H7DTegdZsxKnPUw4XgVuhM \<br>    | protoc --decode PBNode combined.proto</pre><pre>Data {<br>  Type: File<br>  Data: &quot;foobar&quot;<br>  filesize: 6<br>}</pre><p>With the better explained output we can now see exactly why the hashes are different. While our content (foobar) is still there so is an description of this block representing a file, and the file size.</p><p>All this might seem like a wasteful use of bytes but trust us: many of the optimizations you might now be thinking about have already been explored and we will get to them later. Instead let’s continue to a more broad overview.</p><h3>Different kinds of UnixFS files</h3><p>In reality most files are longer than mere 6 bytes. However, the blocks cannot have any size but should be limited by an upper bound. When the file with its UnixFS representation becomes longer than the limit, it needs to be chunked into smaller pieces. To glue them together we need links to other blocks, which would be identified with CIDs as previously discussed.</p><p>Let’s continue exploration with the 5821982 byte (about 5 MiB) rust-ipfs 0.1.0 release tarball <a href="https://github.com/rs-ipfs/rust-ipfs/releases/download/v0.1.0/ipfs_v0.1.0_linux-amd64.tar.gz">ipfs_v0.1.0_linux-amd64.tar.gz</a>. Adding it to go-ipfs 0.5 gives us version 0 CID of QmbJgZEEzYnCFRutsYuixybR9iJDYDiriJX126SWNeomrH. By looking at the block data with protoc --decode PBNode combined.proto we can see a structure like:</p><pre>$ ipfs block get QmbJgZEEzYnCFRutsYuixybR9iJDYDiriJX126SWNeomrH \<br>    | protoc --decode PBNode combined.proto<br>Data {<br>  Type: File<br>  filesize: 5821982<br>  blocksizes: 262144    # ---\ <br>  ...                   #    | 23 chunks<br>  blocksizes: 54814     # ---/<br>}<br>Links {                 # ---\<br>  Hash: &quot;cid0&quot;          #    |<br>  Name: &quot;&quot;              #    |<br>  Tsize: 262158         #    |<br>}                       #    |<br>... repeated Links {}   #    | 23 links<br>Links {                 #    |<br>  Hash: &quot;cid22&quot;         #    |<br>  Name: &quot;&quot;              #    |<br>  Tsize: 54828          #    |<br>}                       # ---/</pre><p>Note: In the above and following listings, we’ve chosen to use short placeholders “cid0” and “cid22” for readability.</p><p>In addition to the already familiar Type and filesize we now have the repeated field blocksizes and repeated Links messages of PBLink but note the absence of Data::Content field as the content is now spread in the linked blocks.</p><p><strong>The ordering of the </strong>blocksizes<strong> and the links matters:</strong> it lets us know that the <strong>tree</strong> starting from the first link, also known as Links/0, has the length of 262144 bytes and represents the 0…262144 bytes of the original file.</p><p>By default dag-pb nodes contain 174 links at most. The 5 MiB tarball does not come close to the limit with the 23 blocks needed to represent it (262144 * 22 + 54814 == 5821982).</p><p>Moving on to working with a larger file, for example the <a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.6.14.tar.xz">linux-5.6.14.tar.xz</a>, will give us a different structure from the ones we have so far covered. Adding the tarball now gives us familiar version 0 CID of QmTEn8ypAkbJXZUXCRHBorwF2jM8uTUW9yRLzrcQouSoD4.</p><p>Inspecting the block with our tools we get:</p><pre>$ ipfs block get QmTEn8ypAkbJXZUXCRHBorwF2jM8uTUW9yRLzrcQouSoD4 \<br>    | protoc --decode PBNode combined.proto<br>Data {<br>  Type: File<br>  filesize: 111812744<br>  blocksizes: 45613056<br>  blocksizes: 45613056<br>  blocksizes: 20586632<br>}<br>Links {<br>  Hash: &quot;cid0&quot;<br>  Name: &quot;&quot;<br>  Tsize: 45623854<br>}<br>Links {<br>  Hash: &quot;cid1&quot;<br>  Name: &quot;&quot;<br>  Tsize: 45623854<br>}<br>Links {<br>  Hash: &quot;cid2&quot;<br>  Name: &quot;&quot;<br>  Tsize: 20591540<br>}</pre><p>Now the decoded version takes almost less space than the decoded version of the smaller file! This is because we are merely seeing the edge of the merkle forest into which the file has been encoded to. At the top level there are links to three separate trees covering the file offsets:</p><ul><li>0…45613056</li><li>45613056…91226112</li><li>91226112…111812744</li></ul><p>First and second trees have both 174 links to the leaves and the third has 79 links.</p><h3>Going deeper</h3><p>In addition to the UnixFS structure covered already, file adding into ipfs can be commonly configured along the following parameters:</p><ul><li>layout</li><li>chunker</li><li>raw leaves and identity hashing</li></ul><p>In go-ipfs and js-ipfs two different layouts are supported: balanced and trickle. The balanced is the default. The layouts specify what the tree looks like. Balanced allows equally direct access to most of the file offsets supporting faster access to parts of the file while trickle layout targets the streaming use case, like streaming a video from the IPFS network. In trickle layout going deeper into the forest there is always leaf data linked as well. The same does not happen with large files with the balanced layout, as most of the data is at the lowest depth, requiring the IPFS to download many intermediate blocks before reaching the leaf nodes.</p><p>Chunker option allows customizing how the file is split into chunks or chunked. In the previous examples, we had seen chunks of two sizes: 262144 and the remainder. This is because of go-ipfs default chunker option size-262144. There has been a lot of exploration of finding better chunkers, which would allow sharing blocks between different files and thus making the network more efficient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*0HiGEyp_T1Be8-mDBUazcw.png" /><figcaption>File chunks. Chunk borders of collapsed nodes are not shown.</figcaption></figure><p>Raw leaves and identity hashing are related and target the leaf nodes with PBNode::Data::Content field, just as we saw with the foobar containing file. Note that these are <a href="https://github.com/ipfs/go-ipfs/blob/6fc9d7a62a4096dba7dc252ceb6225d373995ddf/docs/experimental-features.md">experimental options in go-ipfs 0.5</a>. With the raw leaves feature the leaf node could had just be six bytes of the raw content without any additional metadata or encoding. Had we used the raw leaves with the six bytes of data, we would soon discover that the produced CID would still take many more bytes to store than the actual content. Identity hashing would be the answer to such cases: the foobar content could just be version 1 CID of bafkqabtgn5xweyls. The CID still has more bytes than the original, but when this content needs to be linked to, the CID is able to fully express it’s content.</p><h3>Encoding Metadata</h3><p>UnixFSv1.5 introduced a solution to embedding unix-like file access rights in mode and modified timestamp (mtime) fields. While the support <a href="https://github.com/ipfs/go-ipfs/issues/6920">hasn’t yet been implemented in go-ipfs</a>, js-ipfs supports them. Both metadata fields appear only at the root of UnixFS item tree, so it‘s easy to migrate even large files to the new format, as only the root descriptor needs to change.</p><p>With a recent js-ipfs installation (0.44.0) we can see them in action:</p><pre>$ echo foobar &gt; file<br>$ ls -l file<br>-rw-r--r-- 1 user group 6 2020-05-25 11:10 file<br>$ jsipfs add --preserve-mode --preserve-mtime file<br>added QmV4bVwPJJKHsoC5qH9XLWkryvjE3x833R7inzSxcsMBTg file<br>$ jsipfs block get QmV4bVwPJJKHsoC5qH9XLWkryvjE3x833R7inzSxcsMBTg | protoc --decode PBNode combined.proto<br>Data {<br>  Type: File<br>  Data: &quot;foobar&quot;<br>  filesize: 6<br>  mode: 33188<br>  mtime {<br>    Seconds: 1590396056<br>    FractionalNanoseconds: 918000<br>  }<br>}</pre><p>By importing the same content with adjusted permissions we can see how the mode changes, but the modified timestamp remains the same:</p><pre>$ chmod ugo+rwx file<br>$ ls -l file<br>-rwxrwxrwx 1 user group 6 2020-05-25 11:10 file<br>$ jsipfs add --preserve-mode --preserve-mtime file<br>added QmdHPCXqrf4MKtsbp69u9NM3zh85xa8JEfTnzMGHhDuCDJ file<br>$ jsipfs block get QmdHPCXqrf4MKtsbp69u9NM3zh85xa8JEfTnzMGHhDuCDJ | protoc --decode PBNode combined.proto<br>Data {<br>  Type: File<br>  Data: &quot;foobar&quot;<br>  filesize: 6<br>  mode: 33279<br>  mtime {<br>    Seconds: 1590396056<br>    FractionalNanoseconds: 918000<br>  }<br>}</pre><p>The mode looks unfamiliar but when converted to octal representation it becomes clearer: 33188 means 0100644. The familiar lowest four bytes define the access bits or in this case 0644 or more commonly known as rw-r--r--. The highest bits in 010xxxx follow the <a href="https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html">sys/stat.h</a> definitions for mode_t and in this case the bits mean S_IFREG or a regular file.</p><p>The mtime is based on the <a href="https://en.wikipedia.org/wiki/Unix_time">Unix epoch</a> on the start of the year 1970. The value of seconds can also be negative for representing the dates before year 1970.</p><h3>More than only files</h3><p>Coming back to the surface after taking a deep dive in to the representation of files in UnixFS, what else can we use them for? Unix-like filesystem representations includes also directories and symbolic links. Symbolic links are the easier of the two. Their content simply tells which file name they should link to, and nothing else.</p><p>Directory representation has two variants: single-block and multi-block directories. Single-block directories are dag-pb nodes with PBLinks to other UnixFS blocks. An example directory from <a href="https://github.com/rs-ipfs/rust-ipfs/tree/7799d888f68ab38d6b771c895b23f5cab0e61fa5/src">rs-ipfs/rust-ipfs/src</a>:</p><pre>$ ipfs block get QmVW9R9zq3wZX656gogFMcPLCTj3rmWfXxP1dBDbffhNvk | protoc --decode PBNode combined.proto<br>Data {<br>  Type: Directory<br>}<br>...<br>Links {<br>  Hash: &quot;cid5&quot;<br>  Name: &quot;lib.rs&quot;<br>  Tsize: 39334<br>}<br>..<br>Links {<br>  Hash: &quot;cid7&quot;<br>  Name: &quot;repo&quot;<br>  Tsize: 32018<br>}</pre><p>We can see the repo (a directory) and the lib.rs (a file) represented as links, with only the Type specified for the UnixFS message under PBNode::Data. Single-block directories are used when the resulting block remains under the block size limit. For larger directories, the block needs to span over multiple blocks.</p><p>Multi-block directories are named hash-mapped array tries or HAMTs. With them, instead of a single block approaching infinite size describing all links to the files and subdirectories and their names, the HAMT sharded directories hash the link names allowing bucketization and efficient random access to nested elements while keeping the overall block sizes finite.</p><h3>Further reading</h3><ul><li><a href="https://github.com/ipfs/specs/blob/master/UNIXFS.md">The UnixFS specification</a></li><li><a href="https://docs-beta.ipfs.io/concepts/content-addressing/">Content addressing and CIDs</a></li><li><a href="https://github.com/ipfs/js-ipfs-unixfs/tree/master/packages/ipfs-unixfs-exporter">js-ipfs’s UnixFS exporter</a></li><li><a href="https://github.com/ipfs/go-unixfs">go-ipfs’s UnixFS implementation</a></li></ul><h3>Equilibrium is a venture studio focused on building core infrastructure for the distributed web.</h3><h3>Interested in joining us? Shoot us a message <a href="https://equilibrium.co/company/">here</a>.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3cf5222b2ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>