forked from ipfs-inactive/js-ipfs-http-client
-
Couldn't load subscription status.
- Fork 0
Support specify hash algorithm in files.add #2
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
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 hidden or 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
hashorhashAlgto be passed tofiles.addin 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-apisupports 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/getandobject/datato accept CIDsThis is necessary because
get-dagnode.jsusesobject/getandobject/dataimmediately after adding files. When specifying--cid-versionor using--hash(which has the effect of setting--cidversion=true)get-dagnode.jsis passed a CIDv1 not a multihash/CIDv0.Previously
get-dagnode.jswas 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/getandobject/dataaccept a CID:requires ipfs-inactive/js-ipfs-unixfs-engine#185