Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Awesome IPLD endeavour #1

Merged
merged 12 commits into from
Oct 26, 2016
89 changes: 25 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# js-ipfs-merkle-dag

# js-ipld-dag-pb

[![](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) [![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![Coverage Status](https://coveralls.io/repos/github/ipld/js-ipld-dag-pb/badge.svg?branch=master)](https://coveralls.io/github/ipld/js-ipld-dag-pb?branch=master)
[![Travis CI](https://travis-ci.org/ipld/js-ipld-dag-pb.svg?branch=master)](https://travis-ci.org/ipld/js-ipld-dag-pb)
[![Circle CI](https://circleci.com/gh/ipld/js-ipld-dag-pb.svg?style=svg)](https://circleci.com/gh/ipld/js-ipld-dag-pb)
[![Dependency Status](https://david-dm.org/ipld/js-ipld-dag-pb.svg?style=flat-square)](https://david-dm.org/ipld/js-ipld-dag-pb)
[![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
> JavaScript Implementation of the IPLD Format MerkleDAG Node in Protobuf.

## Table of Contents

Expand All @@ -23,37 +24,17 @@
## Install

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

## Architecture

```markdown
┌────────────────────┐
│ DAGService │
└────────────────────┘
┌────────────────────┐
│ BlockService │
└────────────────────┘
> npm i ipld-dag-pb
```

**DAGService** - The DAGService offers an interface to interact directly with a MerkleDAG object (composed by one or more DAGNodes that are linked), using the BlockService to store and fetch the DAGNodes as it needs them

[**BlockService** - The BlockService uses IPFS Repo as the local datastore for blocks and an IPFS Exchange compliant implementation to fetch blocks from the network.](https://github.com/ipfs/js-ipfs-block-service)

A DAGNode and DAGLink are data structures made available on this module.

## Usage

```js
const ipfsMDAG = require('ipfs-merkle-dag')
const dagPB = require('ipld-dag-pb')

// then, to access each of the components
ipfsMDAG.DAGService
ipfsMDAG.DAGNode
ipfsMDAG.DAGLink
dagPB.DAGNode
dagPB.resolver
```

## API
Expand All @@ -63,7 +44,7 @@ ipfsMDAG.DAGLink
Create a new DAGNode

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

#### `addNodeLink`
Expand All @@ -87,9 +68,9 @@ var node = new ipfsMDAG.DAGNode([<data>, <[links]>])
> removes a link from the node by the hash of the linked node


#### `copy`
#### `clone`

> creates a copy of the MerkleDAG Node
> creates a clone of the MerkleDAG Node

#### `size`

Expand All @@ -99,15 +80,17 @@ var node = new ipfsMDAG.DAGNode([<data>, <[links]>])

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

#### `multihash`
#### `cid()`

#### `multihash()`

> returns the multihash (default: sha2-256)

#### `marshal`
#### `serialize()`

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

#### `unMarshal`
#### `deserialize()`

> deserializes a node encoded using protobuf

Expand All @@ -124,38 +107,16 @@ var node = new ipfsMDAG.DAGNode([<data>, <[links]>])
Create a new DAGLink

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

### 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`
### Local Resolver (to be used by the IPLD Resolver)

> fetches a node and all of its links (if possible) as pull-stream
#### `resolver.resolve`

#### `remove`
#### `resolver.tree`

> deletes a node
#### `resolver.patch`

## License

Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "ipfs-merkle-dag",
"version": "0.7.3",
"description": "A JavaScript implementations of the IPFS MerkleDAG implementations (protobufs)",
"main": "lib/index.js",
"name": "ipld-dag-pb",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget to deprecate the latest versions of these modules on npm with a message that they were renamed

"version": "0.0.1",
"description": "JavaScript Implementation of the MerkleDAG Node in Protobuf.",
"main": "src/index.js",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: change before merge

"jsnext:main": "src/index.js",
"scripts": {
"lint": "aegir-lint",
Expand Down Expand Up @@ -35,6 +35,7 @@
"url": "https://github.com/ipfs/js-ipfs-merkle-dag.git"
},
"dependencies": {
"cids": "^0.1.1",
"ipfs-block": "^0.3.0",
"is-ipfs": "^0.2.0",
"multihashes": "^0.2.2",
Expand All @@ -59,4 +60,4 @@
"rimraf": "^2.5.4",
"run-series": "^1.1.4"
}
}
}
Loading