js-ipfs-merkle-dag 0,0 travis-ci npm

IPFS Merkle DAG JavaScript Implementation

IPFS Merkle DAG JavaScript Implementation

Dependency Status js-standard-style

JavaScript Implementation of the DAGService and DAGNode data structure

Architecture

┌────────────────────┐
│   DAGService       │
└────────────────────┘
           │
           ▼
┌────────────────────┐
│   BlockService     │
└────────────────────┘

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.

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

Usage

$ npm i ipfs-merkle-dag
const ipfsMDAG = require('ipfs-merkle-dag')

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

DAGNode

Create a new DAGLink

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

Create a new DAGNode

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 DAGLinks 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

deletes a node

License

LICENSE

Related Repositories

js-ipfs-merkle-dag

js-ipfs-merkle-dag

IPFS Merkle DAG JavaScript Implementation ...


Top Contributors

diasdavid vijayee nginnever dignifiedquire noffle substack RichardLitt

Dependencies

package version
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
stable ^0.1.5
dev aegir ^3.0.1
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
ncp ^2.0.0
pre-commit ^1.1.2
rimraf ^2.5.0
run-series ^1.1.4

Releases

-   v0.6.0 zip tar
-   v0.5.1 zip tar
-   v0.5.0 zip tar
-   v0.4.3 zip tar
-   v0.4.2 zip tar
-   v0.4.1 zip tar
-   v0.4.0 zip tar
-   v0.3.0 zip tar
-   v0.2.1 zip tar
-   v0.2.0 zip tar
-   v0.1.1 zip tar
-   v0.1.0 zip tar
-   v0.0.2 zip tar