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

refactor: export CID instances not strings or buffers #19

Merged
merged 4 commits into from
Mar 8, 2019

Conversation

alanshaw
Copy link
Contributor

@alanshaw alanshaw commented Feb 27, 2019

This PR updates the exporter to remove the hash property and replace it with a cid property in yielded objects.

I actually ended up doing this because there's a bug in the "raw" resolver - the objects it yields have a "hash" property not a "multihash" property like file, object and dir. This was causing problems with the CIDv1 base32 work where v1 forces raw leaves and we start using that raw resolver which obviously then gives us back undefined when accessing the "multihash" prop. That file probably needs more/better tests. EDIT: added a test

The upshot is that I solve that issue, as well as make progress towards ipfs-inactive/interface-js-ipfs-core#394 and hopefully make some performance gains by not having to do so much conversion between string/buffer/CID. Hooray!

This PR updates the exporter to remove the `hash` property and replace it with a `cid` property in exported objects.

refs ipfs-inactive/interface-js-ipfs-core#394

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
@ghost ghost assigned alanshaw Feb 27, 2019
@ghost ghost added the in progress label Feb 27, 2019
License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
alanshaw added a commit to ipfs-inactive/js-ipfs-mfs that referenced this pull request Feb 27, 2019
Allows MFS to use the unixfs exporter that exports CIDs without API changes.

refs ipfs-inactive/interface-js-ipfs-core#394

Depends on:

* [ ] ipfs-inactive/js-ipfs-unixfs-exporter#19

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
alanshaw added a commit to ipfs/js-ipfs that referenced this pull request Feb 27, 2019
Allows IPFS to use the unixfs exporter that exports CID instances _without_ API changes.

refs ipfs-inactive/interface-js-ipfs-core#394

Depends on:

* [ ] ipfs-inactive/js-ipfs-mfs#44
* [ ] ipfs-inactive/js-ipfs-unixfs-exporter#19

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
@alanshaw alanshaw marked this pull request as ready for review February 27, 2019 19:16
License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
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.

Down with strings!

@achingbrain achingbrain merged commit 6d65368 into master Mar 8, 2019
@achingbrain achingbrain deleted the refactor/export-cid-instances branch March 8, 2019 09:56
@ghost ghost removed the in progress label Mar 8, 2019
alanshaw added a commit to ipfs/js-ipfs that referenced this pull request Mar 18, 2019
Allows IPFS to use the unixfs exporter that exports CID instances _without_ API changes.

refs ipfs-inactive/interface-js-ipfs-core#394

Depends on:

* [ ] ipfs-inactive/js-ipfs-mfs#44
* [ ] ipfs-inactive/js-ipfs-unixfs-exporter#19

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
alanshaw added a commit to ipfs/js-ipfs that referenced this pull request Mar 18, 2019
Allows IPFS to use the unixfs exporter that exports CID instances _without_ API changes.

Next step is to get the unixfs importer to do the same and then make a breaking interface JS IPFS core API change to ensure we're always returning CID instances not strings for add, ls etc etc.

refs ipfs-inactive/interface-js-ipfs-core#394

Depends on:

* [x] ipfs-inactive/js-ipfs-mfs#44
* [x] ipfs-inactive/js-ipfs-unixfs-exporter#19

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
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