This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 299
Support specify hash algorithm in files.add #597
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
daviddias
suggested changes
Sep 8, 2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nitpicks, otherwise LGTM 👍
src/object/get.js
Outdated
@@ -14,7 +14,7 @@ const lruOptions = { | |||
const cache = LRU(lruOptions) | |||
|
|||
module.exports = (send) => { | |||
return promisify((multihash, options, callback) => { | |||
return promisify((hash, options, callback) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is going to support both, better call it cid
src/object/get.js
Outdated
@@ -24,21 +24,24 @@ module.exports = (send) => { | |||
options = {} | |||
} | |||
|
|||
let cid, b58Hash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We default to declare each variable in separate lines. Mind replacing for:
let cid
let b58Hash
Also, with the added support to cid, makes sense to call it cidB58Str
daviddias
approved these changes
Sep 8, 2017
dryajov
pushed a commit
that referenced
this pull request
Oct 2, 2017
* support support specify hash alg * Add test for add with --hash option. Pass raw cid/multihash to ipfs object get/data * Allow object get/data to accept CID * Var naming tweaks from review
dryajov
pushed a commit
that referenced
this pull request
Oct 2, 2017
* support support specify hash alg * Add test for add with --hash option. Pass raw cid/multihash to ipfs object get/data * Allow object get/data to accept CID * Var naming tweaks from review
daviddias
pushed a commit
that referenced
this pull request
Oct 18, 2017
* Adds wiring for a progress bar Passes the progress bar option for tranfers over http. Progress is shown for your payload being streamed upto the server. There is a pause. Then you get your list of files. * feat: Support specify hash algorithm in files.add (#597) * support support specify hash alg * Add test for add with --hash option. Pass raw cid/multihash to ipfs object get/data * Allow object get/data to accept CID * Var naming tweaks from review * feat: track progress events * tesT: add more tests * fix: tidy up tests * feat: send errors as trailer headers * fix: remove .only from tests * feat: signal error on reponse stream if x-stream-error * test: adding tests for trailer header errors * chore: update interface-ipfs-core * chore: upgrade to latest interface-ipfs-core
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Specify multihash hashing alogrithm
This allows the optional param
hash
orhashAlg
to be passed tofiles.add
in order to specify the hash algorithm that should be used when generating the multihash(es) for the added content.This PR also is more strict about what query string options
js-ipfs-api
supports by pulling out the supported params into a new query string object.It also allows camel case aliases for params that are dash separated. This is because the HTTP API uses dash separated param names, but it is far easier to use camel case param names for internal APIs.
The other reason for allowing these aliases is because this code may be called when talking to a remote IPFS instance via the CLI where the qs params will have already been converted into camelCase.
Change
object/get
andobject/data
to accept CIDsThis is necessary because
get-dagnode.js
usesobject/get
andobject/data
immediately after adding files. When specifying--cid-version
or using--hash
(which has the effect of setting--cidversion=true
)get-dagnode.js
is passed a CIDv1 not a multihash/CIDv0.Previously
get-dagnode.js
was extracting a multihash from a CID and sending that, effectively downgrading a CIDv1 to a CIDv0.That causes the object to not be found (see ipfs-inactive/js-ipfs-unixfs-engine#185) since you have to retrieve using the same CID version as the data was stored.
This actually brings js-ipfs more in line with go-ipfs. Where both
object/get
andobject/data
accept a CID: