Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

feat: dag.workbench API #114

Closed
wants to merge 4 commits into from
Closed
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
28 changes: 4 additions & 24 deletions API/dag/README.md
Original file line number Diff line number Diff line change
@@ -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.
40 changes: 40 additions & 0 deletions src/dag-workbench.js
Original file line number Diff line number Diff line change
@@ -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', () => {
})
})
}
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')