# Blocks, direct, recursive, indirect....oh my!

**URL:** <https://discuss.ipfs.tech/t/blocks-direct-recursive-indirect-oh-my/13579>\
**Category:** Help\
**Created:** [February 25, 2022, 6:42pm UTC](https://discuss.ipfs.tech/t/blocks-direct-recursive-indirect-oh-my/13579 "2022-02-25T18:42:56Z")\
**Posts on this page:** 4\
**Page:** 1

<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:** [February 25, 2022, 6:42pm UTC](https://discuss.ipfs.tech/t/blocks-direct-recursive-indirect-oh-my/13579/1 "2022-02-25T18:42:56Z")

</div>

I’m looking for a clarification of pin types and behavior. The [docs](https://docs.ipfs.io/how-to/pin-files/) mentions direct, recursive, and indirect in reference to blocks and the CLI refers to objects. I’m just a little confused. So if I pin an object, say a file, is the object direct pinned and the child blocks indirectly pinned? What gets a recursive pin? Does the root object get a recursive pin and all the child objects get indirect pins or is everything under the root get a recursive pin and child blocks indirect?

If you have a direct pin and it that is then recursively pinned does the recursive pin get clobbered by the recursive pin or does it now have two pins, one recursive and one direct? In that case of a preexisting direct pin that is then pinned recursively, if you now remove the recursive pin is that file now unpinned?

Is there a way to discover the recursive pin that is causing the indirect pin?

---

<div class="post-metadata">

**Author:** ![Jorropo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jorropo/32/3230_2.png) [@Jorropo](https://discuss.ipfs.tech/u/Jorropo)\
**Post date:** [February 25, 2022, 6:56pm UTC](https://discuss.ipfs.tech/t/blocks-direct-recursive-indirect-oh-my/13579/2 "2022-02-25T18:56:31Z")

</div>

> [@zacharywhitley](#):
>
> So if I pin an object, say a file, is the object direct pinned and the child blocks indirectly pinned?

No the file is recursively pinned and the descendant blocks are indirectly pinned.

Note: descendant ~= childs, except child blocks is a direct link from a parrent to a child. Descendant include childs of childs, childs of childs of childs, …

> [@zacharywhitley](#):
>
> Does the root object get a recursive pin and all the child objects get indirect pins or is everything under the root get a recursive pin and child blocks indirect?

The root block gets recursive, all descendants gets indirect.

> [@zacharywhitley](#):
>
> If you have a direct pin and it that is then recursively pinned does the recursive pin get clobbered by the recursive pin or does it now have two pins, one recursive and one direct?

Direct pins just pin one block, without caring for anything else.

IPFS runs a touching GC for the blocks, so all pin types are runned and the most powerfull one is kept.  
So if a block is pinned twice, once as direct and once as indirect, you store one copy only.  
Unpinning the recursive root will remove the indirect status, however the direct status will stay on.

> [@zacharywhitley](#):
>
> Is there a way to discover the recursive pin that is causing the indirect pin?

I don’t know of any, that info would be really hard to get infact, due to the touching nature of the GC.  
Even if refcounting become a thing, that still would be hard.

---

<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:** [February 25, 2022, 7:51pm UTC](https://discuss.ipfs.tech/t/blocks-direct-recursive-indirect-oh-my/13579/3 "2022-02-25T19:51:50Z")

</div>

So it seems like most of the time it’s going to be a recursive pin + indirectly pinned. I’m wondering when you would ever directly pin a single block unless it was just a really small file inlined with a single block. Also why make the distinction between direct and recursive and not just make a single block a recursive with no descendants?

---

<div class="post-metadata">

**Author:** ![Jorropo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jorropo/32/3230_2.png) [@Jorropo](https://discuss.ipfs.tech/u/Jorropo)\
**Post date:** [February 25, 2022, 8:40pm UTC](https://discuss.ipfs.tech/t/blocks-direct-recursive-indirect-oh-my/13579/4 "2022-02-25T20:40:46Z")

</div>

direct pinning is an advanced feature, I don’t see why you would use it unless you do some IPLD trickery magic and need this kind of advanced feature.

TLDR just use recursive it’s fine
