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

feat: the dag resolve and dag get #116

Merged
merged 1 commit into from
Feb 9, 2017
Merged
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
34 changes: 14 additions & 20 deletions API/dag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ dag API

##### `Go` **WIP**

##### `JavaScript` - ipfs.dag.put(dagNode, formatMulticodec, hashAlg, callback)
##### `JavaScript` - ipfs.dag.put(dagNode, options, 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.
- `options` - a object that might contain the follwing values:
- `format` - The IPLD format multicodec.
- `hashAlg` - The hash algorithm to be used over the serialized dagNode.
- `cid` - the CID of the node passed.
- **Note** - You should only pass the CID or the format + hashAlg pair and not both
- `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.
Expand All @@ -24,23 +27,14 @@ If no `callback` is passed, a [promise][] is returned.

##### `Go` **WIP**

##### `JavaScript` - ipfs.dag.get(cid, callback)
##### `JavaScript` - ipfs.dag.get(cid [, path, options], callback)

- `cid` is a [CID][https://github.com/ipfs/js-cid] instance.
- `cid` - a [CID][https://github.com/ipfs/js-cid] instance.
- `path` - the path to be resolved. Optional.
- `options` - a object that might contain the following values:
- `localResolve` - bool - if set to true, it will avoid resolving through different objects.

`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.
`callback` must follow `function (err, result) {}` signature, where `err` is an error if the operation was not successful and `result` is an object containing:

#### `dag.resolve`

> Resolves an IPLD path

##### `Go` **WIP**

##### `JavaScript` - ipfs.dag.resolve(cid, path, callback)

- `cid` is a [CID][https://github.com/ipfs/js-cid] instance.
- `path` is a String that represents a valid path to be resolved

`callback` must follow `function (err, value) {}` signature, where `err` is an error if the operation was not successful and `value` is the value it was retrieved.

If no `callback` is passed, a [promise][] is returned.
- `value` - the value or node that was fetched during the get operation.
- `remainderPath` - The remainder of the Path that the node was unable to resolve or what was left in a localResolve scenario.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@
"ipld-dag-pb": "^0.9.4",
"multiaddr": "^2.2.0",
"multihashes": "^0.3.2",
"pull-stream": "^3.5.0",
"readable-stream": "2.2.2"
},
"devDependencies": {
"aegir": "^9.4.0"
"aegir": "^10.0.0"
},
"contributors": [
"David Dias <daviddias.p@gmail.com>",
Expand All @@ -53,4 +54,4 @@
"haad <haad@headbanggames.com>",
"nginnever <ginneversource@gmail.com>"
]
}
}
142 changes: 0 additions & 142 deletions src/dag-resolve.js

This file was deleted.

Loading