-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: new test repo out of go-ipfs v0.4.10
- Loading branch information
Showing
38 changed files
with
716 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/ip4/127.0.0.1/tcp/5001 |
4 changes: 0 additions & 4 deletions
4
test/test-repo/blocks/2F/CIQEUWUVLBXVFYSYCHHSCRTXCYHGIOBXKWUMKFR3UPAFHQ5WK5362FQ.data
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-101 Bytes
test/test-repo/blocks/75/CIQMB7DLJFKD267QJ2B5FJNHZPTSVA7IB6OHXSQ2XSVEEKMKK6RT75I.data
Binary file not shown.
3 changes: 0 additions & 3 deletions
3
test/test-repo/blocks/AE/CIQONICFQZH7QVU6IPSIM3AK7AD554D3BWZPAGEAQYQOWMFZQDUUAEI.data
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-309 Bytes
test/test-repo/blocks/AP/CIQHAKDLTL5GMIFGN5YVY4BA22FPHUIODJEXS4LCTQDWA275XAJDAPI.data
Binary file not shown.
4 changes: 0 additions & 4 deletions
4
test/test-repo/blocks/C4/CIQDDZ5EDQK5AP7LRTLZHQZUR2R3GECRFV3WPKNL7PL2SKFIL2LXC4Y.data
This file was deleted.
Oops, something went wrong.
Binary file renamed
BIN
+10.5 KB
...TQ7R247ZI7KJWP3QWPQYS43LFULQC5ANLQFI.data → ...7SYTVOFIEO5657YM3T6DTHFRQYSUZAGRLEPY.data
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
test/test-repo/blocks/FJ/CIQMSSWEB56MYVN7BGLPIMICMCRBABQCR6FC5CFHLZV74LDT2PZIFJQ.data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/ | ||
" ;)�=֝ޤ\S�jX��aJ�,d��U�U8�+v�direct�T2 | ||
" ^��5'��T)�aX��+����L'TZBAJ| recursive�U |
24 changes: 0 additions & 24 deletions
24
test/test-repo/blocks/FN/CIQIXBZMUTXFC5QIGMLJNXLLHZOPGSL2PBC65D4UIVWM6TI5F5TAFNI.data
This file was deleted.
Oops, something went wrong.
308 changes: 308 additions & 0 deletions
308
test/test-repo/blocks/G7/CIQCDCXJ6563LCORPOAY63YIR5EM5R4TXRVPZC2BWPOB5FNVRYEXG7I.data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,308 @@ | ||
|
||
�c�c# IPFS Repo JavaScript Implementation | ||
|
||
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) | ||
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) | ||
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) | ||
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) | ||
[![Build Status](https://travis-ci.org/ipfs/js-ipfs-repo.svg)](https://travis-ci.org/ipfs/js-ipfs-repo) [![Circle CI](https://circleci.com/gh/ipfs/js-ipfs-repo.svg?style=svg)](https://circleci.com/gh/ipfs/js-ipfs-repo) | ||
[![Coverage Status](https://coveralls.io/repos/github/ipfs/js-ipfs-repo/badge.svg?branch=master)](https://coveralls.io/github/ipfs/js-ipfs-repo?branch=master) [![Dependency Status](https://david-dm.org/diasdavid/js-peer-id.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-repo) | ||
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) | ||
![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square) | ||
![](https://img.shields.io/badge/Node.js-%3E%3D4.0.0-orange.svg?style=flat-square) | ||
|
||
[![Sauce Test Status](https://saucelabs.com/browser-matrix/ipfs-js-repo.svg)](https://saucelabs.com/u/ipfs-js-repo) | ||
|
||
> 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](https://github.com/ipfs/specs/tree/master/repo) in JavaScript. | ||
|
||
## Table of Contents | ||
|
||
- [Background](#background) | ||
- [Install](#install) | ||
- [npm](#npm) | ||
- [Use in Node.js](#use-in-nodejs) | ||
- [Use in a browser with browserify, webpack or any other bundler](#use-in-a-browser-with-browserify-webpack-or-any-other-bundler) | ||
- [Use in a browser Using a script tag](#use-in-a-browser-using-a-script-tag) | ||
- [Usage](#usage) | ||
- [API](#api) | ||
- [Contribute](#contribute) | ||
- [License](#license) | ||
|
||
## Background | ||
|
||
Here is the architectural reasoning for this repo: | ||
|
||
```bash | ||
┌────────────────────────────────────────┐ | ||
│ IPFSRepo │ | ||
└────────────────────────────────────────┘ | ||
┌─────────────────┐ | ||
│ / │ | ||
├─────────────────┤ | ||
│ Datastore │ | ||
└─────────────────┘ | ||
│ | ||
┌───────────┴───────────┐ | ||
│ │ | ||
┌─────────────────┐ ┌─────────────────┐ | ||
│ /blocks │ │ /datastore │ | ||
├─────────────────┤ ├─────────────────┤ | ||
│ Datastore │ │ LevelDatastore │ | ||
└─────────────────┘ └─────────────────┘ | ||
|
||
┌────────────────────────────────────────┐ ┌────────────────────────────────────────┐ | ||
│ IPFSRepo - Default Node.js │ │ IPFSRepo - Default Browser │ | ||
└────────────────────────────────────────┘ └────────────────────────────────────────┘ | ||
┌─────────────────┐ ┌─────────────────┐ | ||
│ / │ │ / │ | ||
├─────────────────┤ ├─────────────────┤ | ||
│ FsDatastore │ │LevelJSDatastore │ | ||
└─────────────────┘ └─────────────────┘ | ||
│ │ | ||
┌───────────┴───────────┐ ┌───────────┴───────────┐ | ||
│ │ │ │ | ||
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ | ||
│ /blocks │ │ /datastore │ │ /blocks │ │ /datastore │ | ||
├─────────────────┤ ├─────────────────┤ ├─────────────────┤ ├─────────────────┤ | ||
│ FlatfsDatastore │ │LevelDBDatastore │ │LevelJSDatastore │ │LevelJSDatastore │ | ||
└─────────────────┘ └─────────────────┘ └─────────────────┘ └─────────────────┘ | ||
``` | ||
|
||
This provides a well defined interface for creating and interacting with an IPFS repo. | ||
|
||
## Install | ||
|
||
### npm | ||
|
||
```sh | ||
> npm install ipfs-repo | ||
``` | ||
|
||
### Use in Node.js | ||
|
||
```js | ||
var IPFSRepo = require('ipfs-repo') | ||
``` | ||
|
||
### Use in a browser with browserify, webpack or any other bundler | ||
|
||
```js | ||
var IPFSRepo = require('ipfs-repo') | ||
``` | ||
|
||
### Use in a browser Using a script tag | ||
|
||
Loading this module through a script tag will make the `IpfsRepo` obj available in the global namespace. | ||
|
||
```html | ||
<script src="https://unpkg.com/ipfs-repo/dist/index.min.js"></script> | ||
<!-- OR --> | ||
<script src="https://unpkg.com/ipfs-repo/dist/index.js"></script> | ||
``` | ||
|
||
## Usage | ||
|
||
Example: | ||
|
||
```js | ||
const Repo = require('ipfs-repo') | ||
const repo = new Repo('/tmp/ipfs-repo') | ||
|
||
repo.init({ cool: 'config' }, (err) => { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
repo.open((err) => { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
console.log('repo is ready') | ||
}) | ||
}) | ||
``` | ||
|
||
This now has created the following structure, either on disk or as an in memory representation: | ||
|
||
``` | ||
├── blocks | ||
│ ├── SHARDING | ||
│ └── _README | ||
├── config | ||
├── datastore | ||
└── version | ||
``` | ||
|
||
## API | ||
|
||
### Setup | ||
|
||
#### `new Repo(path[, options])` | ||
|
||
Creates an IPFS Repo. | ||
|
||
Arguments: | ||
|
||
* `path` (string, mandatory): the path for this repo | ||
* `options` (object, optional): may contain the following values | ||
* `lock` (string, defaults to `"fs"` in Node.js, `"memory"` in the browser): what type of lock to use. Lock has to be acquired when opening. | ||
* `storageBackends` (object, optional): may contain the following values, which should each be a class implementing the [datastore interface](https://github.com/ipfs/interface-datastore#readme): | ||
* `root` (defaults to [`datastore-fs`](https://github.com/ipfs/js-datastore-fs#readme) in Node.js and [`datastore-level`](https://github.com/ipfs/js-datastore-level#readme) in the browser). Defines the back-end type used for gets and puts of values at the root (`repo.set()`, `repo.get()`) | ||
* `blocks` (defaults to [`datastore-fs`](https://github.com/ipfs/js-datastore-fs#readme) in Node.js and [`datastore-level`](https://github.com/ipfs/js-datastore-level#readme) in the browser). Defines the back-end type used for gets and puts of values at `repo.blocks`. | ||
* `datastore` (defaults to [`datastore-level`](https://github.com/ipfs/js-datastore-level#readme)). Defines the back-end type used as the key-valye store used for gets and puts of values at `repo.datastore`. | ||
|
||
```js | ||
const repo = new Repo('path/to/repo') | ||
``` | ||
|
||
#### `repo.init (callback)` | ||
|
||
Creates the necessary folder structure inside the repo. | ||
|
||
#### `repo.open (callback)` | ||
|
||
Locks the repo. | ||
|
||
#### `repo.close (callback)` | ||
|
||
Unlocks the repo. | ||
|
||
#### `repo.exists (callback)` | ||
|
||
Tells whether this repo exists or not. Calls back with `(err, bool)`. | ||
|
||
### Repos | ||
|
||
Root repo: | ||
|
||
#### `repo.put (key, value:Buffer, callback)` | ||
|
||
Put a value at the root of the repo. | ||
|
||
* `key` can be a buffer, a string or a [Key](https://github.com/ipfs/interface-datastore#keys). | ||
|
||
#### `repo.get (key, callback)` | ||
|
||
Get a value at the root of the repo. | ||
|
||
* `key` can be a buffer, a string or a [Key](https://github.com/ipfs/interface-datastore#keys). | ||
* `callback` is a callback function `function (err, result:Buffer)` | ||
|
||
[Blocks](https://github.com/ipfs/js-ipfs-block#readme): | ||
|
||
#### `repo.blocks.put (block:Block, callback)` | ||
|
||
* `block` should be of type [Block](https://github.com/ipfs/js-ipfs-block#readme). | ||
|
||
#### `repo.blocks.putMany (blocks, callback)` | ||
|
||
Put many blocks. | ||
|
||
* `block` should be an array of type [Block](https://github.com/ipfs/js-ipfs-block#readme). | ||
|
||
#### `repo.blocks.get (cid, callback)` | ||
|
||
Get block. | ||
|
||
* `cid` is the content id of [type CID](https://github.com/ipld/js-cid#readme). | ||
* `callback` is a callback function `function (err, result:Buffer)` | ||
|
||
Datastore: | ||
|
||
#### `repo.datastore` | ||
|
||
This is contains a full implementation of [the `interface-datastore` API](https://github.com/ipfs/interface-datastore#api). | ||
|
||
|
||
### Utils | ||
|
||
#### `repo.config` | ||
|
||
Instead of using `repo.set('config')` this exposes an API that allows you to set and get a decoded config object, as well as, in a safe manner, change any of the config values individually. | ||
|
||
##### `repo.config.set(key:string, value, callback)` | ||
|
||
Set a config value. `value` can be any object that is serializable to JSON. | ||
|
||
* `key` is a string specifying the object path. Example: | ||
|
||
```js | ||
repo.config.set('a.b.c', 'c value', (err) => { | ||
if (err) { throw err } | ||
repo.config.get((err, config) => { | ||
if (err) { throw err } | ||
assert.equal(config.a.b.c, 'c value') | ||
}) | ||
}) | ||
``` | ||
|
||
##### `repo.config.get(value, callback)` | ||
|
||
Set the whole config value. `value` can be any object that is serializable to JSON. | ||
|
||
##### `repo.config.get(key:string, callback)` | ||
|
||
Get a config value. `callback` is a function with the signature: `function (err, value)`, wehre the ` | ||
value` is of the same type that was set before. | ||
|
||
* `key` is a string specifying the object path. Example: | ||
|
||
```js | ||
repo.config.get('a.b.c', (err, value) => { | ||
if (err) { throw err } | ||
console.log('config.a.b.c = ', value) | ||
}) | ||
``` | ||
|
||
##### `repo.config.get(callback)` | ||
|
||
Get the entire config value. `callback` is a function with the signature: `function (err, configValue:Object)`. | ||
|
||
#### `repo.config.exists(callback)` | ||
|
||
Whether the config sub-repo exists. Calls back with `(err, bool)`. | ||
|
||
#### `repo.version` | ||
|
||
##### `repo.version.get (callback)` | ||
|
||
Gets the repo version. | ||
|
||
##### `repo.version.set (version:number, callback)` | ||
|
||
Sets the repo version | ||
|
||
#### `repo.apiAddr` | ||
|
||
#### `repo.apiAddr.get (callback)` | ||
|
||
Gets the API address. | ||
|
||
#### `repo.apiAddr.set (value, callback)` | ||
|
||
Sets the API address. | ||
|
||
* `value` should be a [Multiaddr](https://github.com/multiformats/js-multiaddr) or a String representing a valid one. | ||
|
||
## Notes | ||
|
||
- [Explanation of how repo is structured](https://github.com/ipfs/js-ipfs-repo/pull/111#issuecomment-279948247) | ||
|
||
## Contribute | ||
|
||
There are some ways you can make this module better: | ||
|
||
- Consult our [open issues](https://github.com/ipfs/js-ipfs-repo/issues) and take on one of them | ||
- Help our tests reach 100% coverage! | ||
|
||
This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). | ||
|
||
[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/contributing.md) | ||
|
||
## License | ||
|
||
[MIT](LICENSE) | ||
�c |
4 changes: 0 additions & 4 deletions
4
test/test-repo/blocks/GQ/CIQH7OEYWXL34RWYL7VXLWEU4FWPVGT24VJT7DUZPTNLF25N25IGGQA.data
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.