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

refactor: object API write methods now return CIDs #896

Merged
merged 2 commits into from
Nov 27, 2018

Conversation

alanshaw
Copy link
Contributor

@alanshaw alanshaw commented Nov 27, 2018

For the back story on this change, please see: ipfs-inactive/interface-js-ipfs-core#388 (review)

BREAKING CHANGE: Object API refactor.

Object API methods that write DAG nodes now return a CID instead of a DAG node. Affected methods:

  • ipfs.object.new
  • ipfs.object.patch.addLink
  • ipfs.object.patch.appendData
  • ipfs.object.patch.rmLink
  • ipfs.object.patch.setData
  • ipfs.object.put

Example:

// Before
const dagNode = await ipfs.object.new()
// After
const cid = await ipfs.object.new() // now returns a CID
const dagNode = await ipfs.object.get(cid) // fetch the DAG node that was created

IMPORTANT: DAGNode instances, which are part of the IPLD dag-pb format have been refactored.

These instances no longer have multihash, cid or serialized properties.

This effects the following API methods that return these types of objects:

  • ipfs.object.get
  • ipfs.dag.get

See ipld/js-ipld-dag-pb#99 for more information.

Bonus, fixes #895

License: MIT
Signed-off-by: Alan Shaw [email protected]

BREAKING CHANGE: Object API refactor.

Object API methods that write DAG nodes now return a CID instead of a DAG node. Affected methods:

* `ipfs.object.new`
* `ipfs.object.patch.addLink`
* `ipfs.object.patch.appendData`
* `ipfs.object.patch.rmLink`
* `ipfs.object.patch.setData`
* `ipfs.object.put`

Example:

```js
// Before
const dagNode = await ipfs.object.new()
```

```js
// After
const cid = await ipfs.object.new() // now returns a CID
const dagNode = await ipfs.object.get(cid) // fetch the DAG node that was created
```

IMPORTANT: `DAGNode` instances, which are part of the IPLD dag-pb format have been refactored.

These instances no longer have `multihash`, `cid` or `serialized` properties.

This effects the following API methods that return these types of objects:

* `ipfs.object.get`
* `ipfs.dag.get`

See ipld/js-ipld-dag-pb#99 for more information.

License: MIT
Signed-off-by: Alan Shaw <[email protected]>
@ghost ghost assigned alanshaw Nov 27, 2018
@ghost ghost added the in progress label Nov 27, 2018
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
@alanshaw alanshaw changed the title [WIP] refactor: object API write methods now return CIDs refactor: object API write methods now return CIDs Nov 27, 2018
Copy link
Contributor

@hugomrdias hugomrdias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM so beautiful seeing so many red line and so few green ones :)

Copy link
Collaborator

@achingbrain achingbrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Memory leak in object.get
3 participants