# Incomprehension of the difference between "chunk" and "block"

**URL:** <https://discuss.ipfs.tech/t/incomprehension-of-the-difference-between-chunk-and-block/14781>\
**Category:** Help\
**Tags:** ipld, files\
**Created:** [July 20, 2022, 10:09am UTC](https://discuss.ipfs.tech/t/incomprehension-of-the-difference-between-chunk-and-block/14781 "2022-07-20T10:09:11Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zesor1](https://avatars.discourse-cdn.com/v4/letter/z/8c91f0/32.png) [@Zesor1](https://discuss.ipfs.tech/u/Zesor1)\
**Post date:** [July 20, 2022, 10:09am UTC](https://discuss.ipfs.tech/t/incomprehension-of-the-difference-between-chunk-and-block/14781/1 "2022-07-20T10:09:11Z")

</div>

Hello,

I am actually reading a lot of documentation of IPFS ecosystem (IPNS, MFS, UNIXFS, IPLD etc…).  
I actually understand the concept of “chunk”, this is a piece of data that corresponds to the leaf of the Merkle DAGs created when you add a file on IPFS.  
I read the doc of IPLD on the git repository : [GitHub - ipld/docs: All you need to know about IPLD](https://github.com/ipld/docs)  
The notion that i don’t understand is a “block”, a “block” is defined first here “So now, with multihash, a single identifier can get us any set of binary data (what we call a “Block”) from anywhere in the world.”  
in “From data to Data Structure” section, below i see that in the section “Block” a block is defined “The term “block” is used to refer to the pairing of a raw binary and a CID.” Below again the doc says in “Node” section that “a block can contain many nodes”.

Can you explain me the truth about about a “block” and the difference between a chunk and a block ?

---

<div class="post-metadata">

**Author:** ![SionoiS](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/sionois/32/5103_2.png) [@SionoiS](https://discuss.ipfs.tech/u/SionoiS)\
**Post date:** [July 20, 2022, 12:23pm UTC](https://discuss.ipfs.tech/t/incomprehension-of-the-difference-between-chunk-and-block/14781/2 "2022-07-20T12:23:37Z")

</div>

Let me try!

Chunks are what is produced by the chunking algorithm.  
Those chunks are then hashed and blocks are hash + chunk OR hash + links to other blocks.

Chunks are not super relevant IMO.

---

<div class="post-metadata">

**Author:** ![Zesor1](https://avatars.discourse-cdn.com/v4/letter/z/8c91f0/32.png) [@Zesor1](https://discuss.ipfs.tech/u/Zesor1)\
**Post date:** [July 20, 2022, 12:31pm UTC](https://discuss.ipfs.tech/t/incomprehension-of-the-difference-between-chunk-and-block/14781/3 "2022-07-20T12:31:02Z")

</div>

Thanks, that’s a little clearer. So a block is a hash + chunk.

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [July 20, 2022, 12:41pm UTC](https://discuss.ipfs.tech/t/incomprehension-of-the-difference-between-chunk-and-block/14781/4 "2022-07-20T12:41:25Z")

</div>

A block is the strict unit of data referenced by a CID. A block is the binary payload that when hashed produces the same CID. A block is always content-addressed.

A block is not the full Merkle-DAG referenced by a root CID, nor anything that has been interpreted/parsed (i.e. a unixfs node).

A chunk is just a piece of binary data, usually becomes a block when it is written to the blockstore, obtaining a CID that can be used to read it later (as a block).

---

<div class="post-metadata">

**Author:** ![Zesor1](https://avatars.discourse-cdn.com/v4/letter/z/8c91f0/32.png) [@Zesor1](https://discuss.ipfs.tech/u/Zesor1)\
**Post date:** [July 20, 2022, 12:55pm UTC](https://discuss.ipfs.tech/t/incomprehension-of-the-difference-between-chunk-and-block/14781/5 "2022-07-20T12:55:58Z")

</div>

Ok i understand, but can you talk about a UnixFS block ? or a block doesn’t store data of UnixFS like if this is a directory and this a file etc…  
IPFS intervenes above the block or in the block ?

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [July 20, 2022, 1:09pm UTC](https://discuss.ipfs.tech/t/incomprehension-of-the-difference-between-chunk-and-block/14781/6 "2022-07-20T13:09:10Z")

</div>

Usually,

a CID references a block. The block can be parsed as a go-merkledag protobuf.

The go-merkledag protobuf has a binary payload which can be parsed as unixfs protobuf.

The unixfs protobuf, when of File type, would have a payload which is the chunk bytes.

Unless you are using “raw leaves”, in which case the CID references the chunk bytes directly.

Spelunking here: [Disk space consumption in IPFS - #4 by hector](https://discuss.ipfs.tech/t/disk-space-consumption-in-ipfs/14516/4)

A block can store anything. The CID gives hints about how to parse it though since it has multicodec in it (that usually is `dag-pb` which indicates the block can be interpreted as a go-merkledag protobuf).

---

<div class="post-metadata">

**Author:** ![zacharywhitley](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/zacharywhitley/32/2670_2.png) [@zacharywhitley](https://discuss.ipfs.tech/u/zacharywhitley)\
**Post date:** [July 20, 2022, 1:22pm UTC](https://discuss.ipfs.tech/t/incomprehension-of-the-difference-between-chunk-and-block/14781/7 "2022-07-20T13:22:31Z")

</div>

Chunks are chopped up pieces of what you’re adding to IPFS. Blocks are the pieces of IPFS. It’s sort of like ordering from Amazon. The stuff you order is like the chunks and you can split up your order into a number of different chunks, the packages you put your chunks into are the IPFS blocks. If they’re raw blocks it’s just a single item and nothing else but Amazon can also throw some extra stuff in there like packing material and advertisements, an invoice, etc. That’s the merkledag. Under this analogy sometimes you’'ll get boxes with nothing but a note saying, “here are the tracking numbers of two other boxes that will either have your stuff or another empty box with more tracking numbers”.

---

<div class="post-metadata">

**Author:** ![Zesor1](https://avatars.discourse-cdn.com/v4/letter/z/8c91f0/32.png) [@Zesor1](https://discuss.ipfs.tech/u/Zesor1)\
**Post date:** [July 20, 2022, 1:25pm UTC](https://discuss.ipfs.tech/t/incomprehension-of-the-difference-between-chunk-and-block/14781/8 "2022-07-20T13:25:43Z")

</div>

Thank for your response @hector that is quite helpful.

---

<div class="post-metadata">

**Author:** ![Zesor1](https://avatars.discourse-cdn.com/v4/letter/z/8c91f0/32.png) [@Zesor1](https://discuss.ipfs.tech/u/Zesor1)\
**Post date:** [July 20, 2022, 1:27pm UTC](https://discuss.ipfs.tech/t/incomprehension-of-the-difference-between-chunk-and-block/14781/9 "2022-07-20T13:27:30Z")

</div>

thank you @zacharywhitley for your response !

---

<div class="post-metadata">

**Author:** ![Zesor1](https://avatars.discourse-cdn.com/v4/letter/z/8c91f0/32.png) [@Zesor1](https://discuss.ipfs.tech/u/Zesor1)\
**Post date:** [July 20, 2022, 1:54pm UTC](https://discuss.ipfs.tech/t/incomprehension-of-the-difference-between-chunk-and-block/14781/10 "2022-07-20T13:54:15Z")

</div>

One more thing @hector , can a block just contains information of this children ? (i.e a block of a folder that points in CID root of this files in the folder) if this is the case what’s the difference between a merkle dag node and a block.

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [July 20, 2022, 2:23pm UTC](https://discuss.ipfs.tech/t/incomprehension-of-the-difference-between-chunk-and-block/14781/11 "2022-07-20T14:23:36Z")

</div>

There is no such thing as a “block of a folder”. A better term is “a unixfs node of type Folder”. Or a “dag-pb node”.

These are all things that come from parsing blocks. Blocks themselves are just a piece of content-addressed data. Interpreting that data and figuring out if it has links etc. is done at a higher layer where they are not called “blocks” anymore.

Also, unixfs is a payload that doesn’t have links. The `dag-pb` node in which it is contained does have links to other nodes. In the case of unixfs folders, those links may actually be the files in the folder. But also big folders use a HAMT, so those links are just pointing to other nodes in a data structure and not the actual files in the folders.

---

<div class="post-metadata">

**Author:** ![Zesor1](https://avatars.discourse-cdn.com/v4/letter/z/8c91f0/32.png) [@Zesor1](https://discuss.ipfs.tech/u/Zesor1)\
**Post date:** [July 20, 2022, 2:56pm UTC](https://discuss.ipfs.tech/t/incomprehension-of-the-difference-between-chunk-and-block/14781/12 "2022-07-20T14:56:11Z")

</div>

> [@hector](#):
>
> those links are just pointing to o

Thank you this answer helped me a lot
