diff --git a/API/dag/README.md b/API/dag/README.md index ae5e3be0..bd1f7abb 100644 --- a/API/dag/README.md +++ b/API/dag/README.md @@ -1,34 +1,14 @@ dag API ======= -#### `dag.put` +> The dag API comes to replace the `object API`, it support the creation and manipulation of dag-pb object, as well as other IPLD formats (i.e dag-cbor, ethereum-block, git, etc) -> Store an IPLD format node +#### `dag.workbench` -##### `Go` **WIP** - -##### `JavaScript` - ipfs.dag.put(dagNode, formatMulticodec, hashAlg, callback) - -`dagNode` - a DAG node that follows one of the supported IPLD formats. - -`formatMulticodec` - The IPLD format multicodec. - -`hashAlg` - The hash algorithm to be used over the serialized dagNode. - -`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful. - -If no `callback` is passed, a [promise][] is returned. - -#### `dag.get` - -> Retrieve an IPLD format node +> Creates a virtual workspace where you can create nodes and delete them, without paying the cost of constantly hashing ##### `Go` **WIP** -##### `JavaScript` - ipfs.object.get(cid, callback) - -`cid` is a [CID][https://github.com/ipfs/js-cid] instance. - -`callback` must follow `function (err, dagNode) {}` signature, where `err` is an error if the operation was not successful and `dagNode` is the IPLD format DAG node retrieved. +##### `JavaScript` - ipfs.dag.workbench(??) If no `callback` is passed, a [promise][] is returned. diff --git a/src/dag-workbench.js b/src/dag-workbench.js new file mode 100644 index 00000000..3863a57d --- /dev/null +++ b/src/dag-workbench.js @@ -0,0 +1,40 @@ +/* eslint-env mocha */ +/* eslint max-nested-callbacks: ["error", 8] */ + +'use strict' + +const expect = require('chai').expect +const dagPB = require('ipld-dag-pb') +const DAGNode = dagPB.DAGNode +const dagCBOR = require('ipld-dag-pb') +// const series = require('async/series') + +module.exports = (common) => { + describe('.dag.workbench', () => { + let ipfs + + before(function (done) { + // CI is slow + this.timeout(20 * 1000) + + common.setup((err, factory) => { + expect(err).to.not.exist + factory.spawnNode((err, node) => { + expect(err).to.not.exist + ipfs = node + done() + }) + }) + }) + + after((done) => { + common.teardown(done) + }) + + describe('callback API', () => { + }) + + describe('promise API', () => { + }) + }) +} diff --git a/src/index.js b/src/index.js index 24b2e4b3..4a4a4e13 100644 --- a/src/index.js +++ b/src/index.js @@ -8,4 +8,5 @@ exports.generic = require('./generic') exports.swarm = require('./swarm') exports.block = require('./block') exports.dht = require('./dht') +exports.dag = require('./dag') exports.pubsub = require('./pubsub')