forked from ipfs-inactive/js-ipfs-http-client
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support specify hash algorithm in files.add #2
Open
alanshaw
wants to merge
20
commits into
master
Choose a base branch
from
files-add-hash-alg1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
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
bfc0c3d
to
19fcd7b
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:requires ipfs-inactive/js-ipfs-unixfs-engine#185