Implementation of the IPFS repo spec (https://github.com/ipfs/specs/tree/master/repo) in JavaScript
This is the implementation of the IPFS repo spec in JavaScript.
┌─────────────────────────────────┐
│ interface defined by Repo Spec │
├─────────────────────────────────┤
│ │ ┌──────────────────────┐
│ │ │ abstract-blob-store │
│ IPFS REPO │─────────────────────────────────▶│ interface │
│ │ ├──────────────────────┤
│ │ │ locks │
└─────────────────────────────────┘ └──────────────────────┘
│
┌──────────┴────┬───────────────┬───────────────┬───────────────┬───────────────┐
▼ ▼ ▼ ▼ ▼ ▼
┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐
│ abstract │ │ abstract │ │ abstract │ │ abstract │ │ abstract │ │ abstract │
│ -blob │ │ -blob │ │ -blob │ │ -blob │ │ -blob │ │ -blob │
│ -store │ │ -store │ │ -store │ │ -store │ │ -store │ │ -store │
│ interface │ │ interface │ │ interface │ │ interface │ │ interface │ │ interface │
├───────────┤ ├───────────┤ ├───────────┤ ├───────────┤ ├───────────┤ ├───────────┤
│ │ │ │ │ │ │ │ │ │ │ │
│ keys │ │ config │ │ datastore │ │ datastore │ │ logs │ │ version │
│ │ │ │ │ │ │ -legacy │ │ │ │ │
└───────────┘ └───────────┘ └───────────┘ └───────────┘ └───────────┘ └───────────┘
IPFS repo exposes a well defined interface by the Repo Spec. Each of the individual repos has an interface defined by abstract-blob-store, this enables us to make IPFS repo portable (running on Node.js vs the browser) and accept different types of storage mechanisms for each repo (fs, levelDB, etc).
- The datastore folder holds the legacy version of datastore, still built in levelDB, there is a current endeavour of pushing it to fs completely.
- The blocks folder is the current version of datastore.
- The keys repo doesn't exist yet, as the private key is simply stored inside config
var blobStore = require('abstract-blob-store') // an in-memory blob store
var IPFSRepo = require('js-ipfs-repo')
var repo = new IPFSRepo('/Users/someone/.ipfs', {
stores: blobStore
})
var IPFSRepo = require('ipfs-repo')
Creates a reference to an IPFS repository at the path path
. This does
not create the repo, but is an object that refers to the repo at such a path.
Valid keys for opts
include:
stores
: either an abstract-blob-store, or a map of the form
{
keys: someBlobStore,
config: someBlobStore,
datastore: someBlobStore,
logs: someBlobStore,
locks: someBlobStore,
version: someBlobStore
}
If you use the former form, all of the sub-blob-stores will use the same store.
Initializes the IPFS repository at the repo's path
. Currently this is a no-op.
Consumes a config object config
(TODO: specification?) By default, init requires the repo not yet exist (by default). Calls the callback cb(err)
on completion or error.
Check if the repo you are going to access already exists. Calls the callback
cb(err, exists)
, where exists
is true or false.
Read/write the version number of the repository. The version number is the repo version number.
Read/write the configuration object of the repository.
Read/write keys inside the repo. This feature will be expanded once IPRS and KeyChain are finalized and implemented on go-ipfs.
Read and write buffers to/from the repo's block store.
WIP
Install via npm:
$ npm i ipfs-repo
There are some ways you can make this module better:
- Consult our open issues and take on one of them
- Make the tests better
- Make the tests work in the Browser