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

use object tests from interface-ipfs-core #267

Merged
merged 1 commit into from
May 13, 2016
Merged

Conversation

daviddias
Copy link
Contributor

@daviddias daviddias commented May 11, 2016

return callback(new Error('Stored object was different from constructed object'))
}

callback(null, node)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order to support the variety of ways ipfs.object.put can be called, I had to break the elegant promise injection that was there before. @dignifiedquire wanna share some wisdom on how we can add promises again, in the most elegant way possible?

Copy link
Contributor

Choose a reason for hiding this comment

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

it's probably best to just wrap the function using sth like this: https://github.com/manuel-di-iorio/promisify-es6

@daviddias
Copy link
Contributor Author

It took me more time to do object.put than I thought, spent too much time looking at the promises thing and I believe that we this new Interface document and tests, I caught a bunch of scenarios where the hash returned and the possible hash created client side would not match, not this last part is all good :)

if (!options.enc) {
tmpObj = { Data: obj.toString(), Links: [] }
} else {
tmpObj = JSON.parse(obj.toString())
Copy link
Contributor

Choose a reason for hiding this comment

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

this should only happen if enc === 'json'

Copy link
Contributor

Choose a reason for hiding this comment

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

wait no, we actually don't want to parse at all in here, that's the job of ipfs itself isn't it?

Copy link
Contributor

Choose a reason for hiding this comment

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

confused

Copy link
Contributor Author

@daviddias daviddias May 12, 2016

Choose a reason for hiding this comment

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

This is for the use case (that people have been doing forever) that goes like:

const obj = {
  Data: new Buffer('Some data').toString(),
  Links: []
}

const buf = new Buffer(JSON.stringify(obj))

Copy link
Contributor

Choose a reason for hiding this comment

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

But why do you need to parse that, you can just pass that to go-ipfs with the encoding

@daviddias daviddias force-pushed the use-interface-ipfs-core branch 5 times, most recently from 646f7c6 to 50bc13a Compare May 13, 2016 14:13
@daviddias
Copy link
Contributor Author

Tests complete. @dignifiedquire @haadcode mind CR'ing this one? This will be the API breaking change that will enable you to jump from js-ipfs-api to js-ipfs with a simple line, @haadcode :)

@daviddias daviddias force-pushed the use-interface-ipfs-core branch 3 times, most recently from 54f90cd to 7852050 Compare May 13, 2016 15:24

send('object/stat', multihash, null, null, callback)
}),
new: promisify((callback) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

what about layouts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried all the other layouts through the CLI and only unixfs-dir works. It seems one of those deprecated features that no one ever used to even notice. I updated the spec accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I made it fully work in js-ipfs :/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would you like to propose that we shim that feature in, although go-ipfs not supporting? All is possible with code 🎤 :D

@daviddias
Copy link
Contributor Author

greeen :D

@daviddias
Copy link
Contributor Author

ok, merging this one :D

@daviddias daviddias merged commit 586b36f into master May 13, 2016
@daviddias daviddias deleted the use-interface-ipfs-core branch May 13, 2016 19:59
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.

2 participants