Skip to content

[WIP] refactor: move to pull-streams #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# API

## DAGNode

Create a new DAGLink

```JavaScript
var link = new ipfsMDAG.DAGLink(<name>, <size>, <hash>)
```

Create a new DAGNode

```JavaScript
var node = new ipfsMDAG.DAGNode([<data>, <[links]>])
```

### `addNodeLink`

> creates a link on node A to node B by using node B to get its multihash

### `addRawLink`

> creates a link on node A to node B by using directly node B multihash

### `updateNodeLink`

> updates a link on the node. *caution* this method returns a copy of the MerkleDAG node

### `removeNodeLink`

> removes a link from the node by name

### `removeNodeLinkByHash`

> removes a link from the node by the hash of the linked node


### `copy`

> creates a copy of the MerkleDAG Node

### `size`

> (property) size of the node, in bytes

### `links`

> (property) an array of `DAGLink`s belonging to the node

### `multihash`

> returns the multihash (default: sha2-256)

### `marshal`

> returns a protobuf serialized version, compatible with go-ipfs MerkleDAG

### `unMarshal`

> deserializes a node encoded using protobuf

### `getPBNode`

> used internally

### `makeLink`

> used internally

## DAGService

### `put`

> stores the node

### `putStream`

> stores nodes using a writable pull-stream

### `get`

> fetches a node by its multihash

### `getStream`

> fetches a node as a pull-stream

### `getRecursive`

> fetches a node and all of its links (if possible)

### `getRecursiveStream`

> fetches a node and all of its links (if possible) as pull-stream

### `remove`

> deletes a node
113 changes: 22 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
# IPFS Merkle DAG JavaScript Implementation
# js-ipfs-merkle-dag


[![](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)
[![Coverage Status](https://coveralls.io/repos/github/ipfs/js-ipfs-merkle-dag/badge.svg?branch=master)](https://coveralls.io/github/ipfs/js-ipfs-merkle-dag?branch=master)
[![Travis CI](https://travis-ci.org/ipfs/js-ipfs-merkle-dag.svg?branch=master)](https://travis-ci.org/ipfs/js-ipfs-merkle-dag)
[![Circle CI](https://circleci.com/gh/ipfs/js-ipfs-merkle-dag.svg?style=svg)](https://circleci.com/gh/ipfs/js-ipfs-merkle-dag)
[![Dependency Status](https://david-dm.org/ipfs/js-ipfs-merkle-dag.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-merkle-dag) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
[![Dependency Status](https://david-dm.org/ipfs/js-ipfs-merkle-dag.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-merkle-dag) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) [![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)

> JavaScript Implementation of the DAGService and DAGNode data structure

## Table of Contents

- [Install](#install)
- [Architecture](#architecture)
- [Usage](#usage)
- [API](#api)
- [Contribute](#contribute)
- [License](#license)

## Install

```bash
$ npm i ipfs-merkle-dag
```

## Architecture

```markdown
Expand All @@ -31,11 +47,7 @@ A DAGNode and DAGLink are data structures made available on this module.

## Usage

```bash
$ npm i ipfs-merkle-dag
```

```javascript
```js
const ipfsMDAG = require('ipfs-merkle-dag')

// then, to access each of the components
Expand All @@ -44,91 +56,10 @@ ipfsMDAG.DAGNode
ipfsMDAG.DAGLink
```

### DAGNode

Create a new DAGLink

```JavaScript
var link = new ipfsMDAG.DAGLink(<name>, <size>, <hash>)
```

Create a new DAGNode

```JavaScript
var node = new ipfsMDAG.DAGNode([<data>, <[links]>])
```

##### addNodeLink

> creates a link on node A to node B by using node B to get its multihash

##### addRawLink

> creates a link on node A to node B by using directly node B multihash

##### updateNodeLink

> updates a link on the node. *caution* this method returns a copy of the MerkleDAG node

##### removeNodeLink

> removes a link from the node by name

##### removeNodeLinkByHash

> removes a link from the node by the hash of the linked node


##### copy

> creates a copy of the MerkleDAG Node

##### size

> (property) size of the node, in bytes

##### links

> (property) an array of `DAGLink`s belonging to the node

##### multihash

> returns the multihash (default: sha2-256)

##### marshal

> returns a protobuf serialized version, compatible with go-ipfs MerkleDAG

##### unMarshal

> deserializes a node encoded using protobuf

##### (used internally) getPBNode

> used internally

##### (used internally) makeLink

> used internally

### DAGService

##### add

> stores the node

##### get

> fetches a node by its multihash

##### getRecursive

> fetches a node and all of its links (if possible)

##### remove
## API

> deletes a node
You can find the [API documentation here](API.md)

## License

[LICENSE](LICENSE.md)
MIT © IPFS
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,27 @@
"url": "https://github.com/ipfs/js-ipfs-merkle-dag.git"
},
"dependencies": {
"bs58": "^3.0.0",
"ipfs-block": "^0.3.0",
"is-ipfs": "^0.2.0",
"multihashes": "^0.2.2",
"multihashing": "^0.2.0",
"protocol-buffers": "^3.1.4",
"multihashing": "^0.2.1",
"protocol-buffers": "^3.1.6",
"pull-traverse": "^1.0.3",
"stable": "^0.1.5"
},
"devDependencies": {
"aegir": "^5.0.1",
"aegir": "^8.0.0",
"bs58": "^3.0.0",
"buffer-loader": "0.0.1",
"chai": "^3.5.0",
"fs-blob-store": "^5.2.1",
"idb-plus-blob-store": "^1.0.0",
"ipfs-block-service": "^0.4.0",
"ipfs-repo": "^0.8.0",
"lodash": "^4.6.1",
"fs-pull-blob-store": "^0.3.0",
"idb-pull-blob-store": "^0.4.0",
"ipfs-block-service": "^0.5.0",
"ipfs-repo": "^0.9.0",
"lodash": "^4.15.0",
"ncp": "^2.0.0",
"pre-commit": "^1.1.2",
"rimraf": "^2.5.0",
"pre-commit": "^1.1.3",
"rimraf": "^2.5.4",
"run-series": "^1.1.4"
}
}
}
51 changes: 0 additions & 51 deletions src/dag-service-batch.js

This file was deleted.

Loading