ipfs / js-ipfs

IPFS implementation in JavaScript
https://js.ipfs.tech
Other
7.44k stars 1.25k forks source link

hey its a little confusing that the docs for get: say "store" - I think they are wrong? #4136

Closed gvelez17 closed 2 years ago

gvelez17 commented 2 years ago

At https://github.com/ipfs/js-ipfs/blob/master/packages/ipfs-core-types/src/dag/index.ts#L52

it says "Store an IPLD format node". and the example is "const cid = await ipfs.dag.put(obj, { storeCodec: 'dag-cbor', hashAlg: 'sha2-512' })"

I suppose the options are the same for get but when you are starting it is a little confusing - is this right?

welcome[bot] commented 2 years ago

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review. In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment. Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

Finally, remember to use https://discuss.ipfs.io if you just need general support.

achingbrain commented 2 years ago

I'm not sure I understand your question.

storeCodec is how the passed object will be encoded in the block that is ultimately added to your local node's repo. This is different to inputCodec which can be used to interpret the passed object - see the ipfs.dag.put docs - https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/DAG.md#options-1

The options for ipfs.dag.get are different, there's no storeCodec/inputCodec because you are reading a block from the repo and the codec is either held in the CID (for v1 CIDs) or implicit dag-pb (for v0 CIDs).

If you think the comment can be improved, please open a PR!