# What is the difference between blockstore and datastore?

**URL:** <https://discuss.ipfs.tech/t/what-is-the-difference-between-blockstore-and-datastore/13842>\
**Category:** Help\
**Tags:** go-ipfs\
**Created:** [March 28, 2022, 1:25am UTC](https://discuss.ipfs.tech/t/what-is-the-difference-between-blockstore-and-datastore/13842 "2022-03-28T01:25:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mansub1029](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/mansub1029/32/6169_2.png) [@mansub1029](https://discuss.ipfs.tech/u/mansub1029)\
**Post date:** [March 28, 2022, 1:25am UTC](https://discuss.ipfs.tech/t/what-is-the-difference-between-blockstore-and-datastore/13842/1 "2022-03-28T01:25:55Z")

</div>

Hello.  
I would like to know what is the difference between `blockstore` and `datastore`.

When I analyzed the code, it seems that `datastore` simply has the function of key-value DB (e.g., Put, Delete, Get, Has)

In `blockstore`, it looks like it uses CID as a key and calls the `datastore` function internally to perform a specific function (e.g., DeleteBlock, GCLock).

In other words, is it right that `blockstore` has `datastore` functions + GC processing?

Thank you.

---

<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:** [March 28, 2022, 1:31am UTC](https://discuss.ipfs.tech/t/what-is-the-difference-between-blockstore-and-datastore/13842/2 "2022-03-28T01:31:55Z")

</div>

> When I analyzed the code, it seems that `datastore` simply has the function of key-value DB (e.g., Put, Delete, Get, Has)

Yes exactly

> In `blockstore` , it looks like it uses CID as a key and calls the `datastore` function internally to perform a specific function (e.g., DeleteBlock, GCLock).

Exactly

`Datastore` is a generic KV store used to store such as MFS metadata, DHTServer data, PeerStore data (note, not the default option), or `blockstore` data.

`Blockstore` only deals with IPLD blocks, some `blockstore` implementations use a `blockstore` as storage (such as for `badgerds`), other writes files on disk (such as `flatfs`).
