-
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
fix: update DAG PUT API s/format/storeCodec #1
Conversation
@@ -37,7 +37,7 @@ async function main () { | |||
} | |||
|
|||
const cid = await client.dag.put(data, { | |||
format: 'dag-test', | |||
storeCodec: 'dag-test', |
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.
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
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.
I'm thinking that this should be changed to client.block.put
to illustrate how to do this correctly with a custom codec, thoughts?
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.
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.
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 |
ok, thanks, ipfs-examples/js-ipfs-examples#77 |
No description provided.