Skip to content
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

fix: update DAG PUT API s/format/storeCodec #1

Closed
wants to merge 1 commit into from
Closed

fix: update DAG PUT API s/format/storeCodec #1

wants to merge 1 commit into from

Conversation

rvagg
Copy link
Contributor

@rvagg rvagg commented Oct 15, 2021

No description provided.

@@ -37,7 +37,7 @@ async function main () {
}

const cid = await client.dag.put(data, {
format: 'dag-test',
storeCodec: 'dag-test',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is currently broken but I want to illustrate the breakage here - when connecting via the http client, you now can't use the DAG PUT API to put arbitrary bytes. I don't believe you could do this even before 0.10.0 with go-ipfs, it only worked with js-ipfs because the http server just invokes the BLOCK PUT API instead. Now, you need to have the codec on the server in both js-ipfs and go-ipfs for this to work, otherwise use the BLOCK PUT API directly.

Ref: ipfs/js-ipfs#3917

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'm thinking that this should be changed to client.block.put to illustrate how to do this correctly with a custom codec, thoughts?

Copy link
Contributor

@achingbrain achingbrain Oct 15, 2021

Choose a reason for hiding this comment

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

The http client doesn't use dag.get either since the server has to serialize the output to transfer it over HTTP, instead it uses block.get internally while presenting the same API as core.

dag.put in the client should now probably do the same thing to maintain API compatibility, otherwise the DAG API becomes completely unusable over HTTP, which you might not even know you are using as a transport (eg: there's a daemon running as a background process and you are using the CLI to interact with it).

This example might be a good place to show how to put/get dag objects using the block API as well as the DAG API though.

@achingbrain
Copy link
Contributor

Nb. PRs to change examples should be opened against https://github.com/ipfs-examples/js-ipfs-examples as these repos sync from that one - see the note in the pr template

@rvagg
Copy link
Contributor Author

rvagg commented Oct 16, 2021

ok, thanks, ipfs-examples/js-ipfs-examples#77

@rvagg rvagg closed this Oct 16, 2021
@rvagg rvagg deleted the rvagg/dag-put-update branch October 16, 2021 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants