Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
feat: dag.get, dag.rm and dag.resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Dec 13, 2016
1 parent b5b166b commit 16ad10c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/core/components/dag.js
@@ -1,11 +1,13 @@
'use strict'

const promisify = require('promisify-es6')
const dagPB = require('ipld-dag-pb')
const CID = require('cids')
// const dagPB = require('ipld-dag-pb')
// const dagCBOR = require('ipld-dag-cbor')

// const CID = require('cids')
// const mh = require('multihashes')

module.exports = function object (self) {
module.exports = function dag (self) {
return {
put: promisify((dagNode, multicodec, hashAlg, callback) => {
// TODO
Expand All @@ -15,17 +17,28 @@ module.exports = function object (self) {
// put in IPLD Resolver

/*
self._ipldResolver.put({
node: node,
cid: new CID(node.multihash)
}
self._ipldResolver.put({
node: node,
cid: new CID(node.multihash)
}
*/
switch (multicodec) {
case 'dag-pb': {} break
case 'dag-cbor': {} break
default:
callback(new Error('IPLD Format not supported'))
}
}),
get: promisify((cid, callback) => {
self.ipldResolver.get(cid, callback)
}),
rm: promisify((cid, callback) => {
// TODO once pinning is complete, this remove operation has to first
// verify that some pinning chain is not broken with the operation
self.ipldResolver.remove(cid, callback)
}),
resolve: promisify((cid, path, callback) => {
// TODO
self.ipldResolver.resolve(cid, path, callback)
})
}
}
20 changes: 20 additions & 0 deletions test/core/both/test-dag.js
@@ -0,0 +1,20 @@
/* eslint-env mocha */

'use strict'

const test = require('interface-ipfs-core')
const IPFSFactory = require('../../utils/factory-core')

let factory

const common = {
setup: function (cb) {
factory = new IPFSFactory()
cb(null, factory)
},
teardown: function (cb) {
factory.dismantle(cb)
}
}

test.dag(common)

0 comments on commit 16ad10c

Please sign in to comment.