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

Commit

Permalink
Merge pull request #1 from ipld/awesome-ipld
Browse files Browse the repository at this point in the history
Awesome IPLD endeavour
  • Loading branch information
daviddias authored Oct 26, 2016
2 parents 893aff1 + 2d3d220 commit da42c59
Show file tree
Hide file tree
Showing 13 changed files with 915 additions and 734 deletions.
91 changes: 21 additions & 70 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,18 +80,10 @@ var node = new ipfsMDAG.DAGNode([<data>, <[links]>])

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

> 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
Expand All @@ -124,38 +97,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
21 changes: 12 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ipfs-merkle-dag",
"version": "0.7.3",
"description": "A JavaScript implementations of the IPFS MerkleDAG implementations (protobufs)",
"name": "ipld-dag-pb",
"version": "0.0.1",
"description": "JavaScript Implementation of the MerkleDAG Node in Protobuf.",
"main": "lib/index.js",
"jsnext:main": "src/index.js",
"scripts": {
Expand Down Expand Up @@ -35,7 +35,8 @@
"url": "https://github.com/ipfs/js-ipfs-merkle-dag.git"
},
"dependencies": {
"ipfs-block": "^0.3.0",
"cids": "^0.2.0",
"ipfs-block": "^0.4.0",
"is-ipfs": "^0.2.0",
"multihashes": "^0.2.2",
"multihashing": "^0.2.1",
Expand All @@ -45,18 +46,20 @@
"stable": "^0.1.5"
},
"devDependencies": {
"aegir": "^8.0.1",
"aegir": "^8.1.2",
"async": "^2.1.2",
"bs58": "^3.0.0",
"buffer-loader": "0.0.1",
"chai": "^3.5.0",
"chai-checkmark": "^1.0.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",
"idb-pull-blob-store": "^0.5.1",
"ipfs-block-service": "^0.6.0",
"ipfs-repo": "^0.10.0",
"lodash": "^4.15.0",
"ncp": "^2.0.0",
"pre-commit": "^1.1.3",
"rimraf": "^2.5.4",
"run-series": "^1.1.4"
}
}
}
Loading

0 comments on commit da42c59

Please sign in to comment.