#ipfs #dag

ipfs-sqlite-block-store

block store for ipfs, using sqlite

27 releases (6 breaking)

new 0.7.1 Sep 27, 2021
0.6.1 Jun 28, 2021
0.3.0 Mar 11, 2021
0.1.6 Dec 28, 2020

#207 in Database interfaces

Download history 389/week @ 2021-06-05 448/week @ 2021-06-12 261/week @ 2021-06-19 219/week @ 2021-06-26 139/week @ 2021-07-03 225/week @ 2021-07-10 222/week @ 2021-07-17 121/week @ 2021-07-24 223/week @ 2021-07-31 239/week @ 2021-08-07 151/week @ 2021-08-14 43/week @ 2021-08-21 56/week @ 2021-08-28 141/week @ 2021-09-04 384/week @ 2021-09-11 432/week @ 2021-09-18

837 downloads per month
Used in 4 crates (3 directly)

MIT/Apache

93KB
2K SLoC

IPFS sqlite block store   Latest Version Docs Badge

Sqlite based block store for content-addressed data like IPLD.

See the module level docs for more details.


lib.rs:

IPFS sqlite block store

A block store for a rust implementation of ipfs.

Concepts

Aliases

An alias is a named pin of a root. When a root is aliased, none of the leaves of the dag pointed to by the root will be collected by gc. However, a root being aliased does not mean that the dag must be complete.

Temporary aliases

A temporary alias is an unnamed alias that is just for the purpose of protecting blocks from gc while a large tree is being constructed. While an alias maps a single name to a single root, a temporary alias can be assigned to an arbitary number of blocks before the dag is finished.

A temporary alias will be deleted as soon as the handle goes out of scope.

Garbage Collection (GC)

GC refers to the process of removing unpinned blocks. It runs only when the configured size targets are exceeded. Size targets contain both the total size of the store and the number of blocks.

GC will run incrementally, deleting blocks until the size targets are no longer exceeded. The order in which unpinned blocks will be deleted can be customized.

Caching

For unpinned blocks, it is possible to customize which blocks have the highest value using a CacheTracker. The default is to do nothing and has no performance overhead.

The most elaborate implemented strategy is to keep track of access times in a separate database, via the SqliteCacheTracker, which has a slight performance overhead.

The performance overhead of writing to an access tracking database on each block read can be mitigated by using the AsyncCacheTracker wrapper to perform the database writes on a different thread.

Usage

Blocking

For blocking usage, use BlockStore. This is the most low level interface.

Major differences to the go-ipfs pinning concept

  • Pinning/aliasing a root does not require that the dag is complete
  • Aliases/named pins as opposed to unnamed and non-reference-counted pins
  • Temporary pins as a mechanism to keep blocks safe from gc while a tree is being constructed

Dependencies

~15MB
~302K SLoC