Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

feat: cid base option #1552

Merged
merged 41 commits into from
Dec 17, 2018
Merged

feat: cid base option #1552

merged 41 commits into from
Dec 17, 2018

Conversation

alanshaw
Copy link
Member

@alanshaw alanshaw commented Sep 10, 2018

Implements an option for the CLI, HTTP API and core (where appropriate) that will allow the user to pick the multibase encoding for any CIDs that are returned as strings.

NOTE Using the CID base option in bitswap, dag and object APIs WILL NOT auto upgrade your CID to v1 if it is a v0 CID and WILL NOT apply the encoding you specified. This is because these APIs return IPLD objects with links and changing the version of the links would result in a different hash for the node if you were to re-add it. Also, the CID you used to retrieve the node wouldn't actually refer to the node you got back any longer. Read this for further context.

This PR adds a --cid-base option to the following CLI commands:

  • jsipfs bitswap stat
  • jsipfs bitswap unwant
  • jsipfs bitswap wantlist
  • jsipfs block put
  • jsipfs block stat
  • jsipfs add
  • jsipfs ls
  • jsipfs object get
  • jsipfs object links
  • jsipfs object new
  • jsipfs object patch add-link
  • jsipfs object patch append-data
  • jsipfs object patch rm-link
  • jsipfs object patch set-data
  • jsipfs object put
  • jsipfs object stat
  • jsipfs pin add
  • jsipfs pin ls
  • jsipfs pin rm
  • jsipfs resolve

Note: these two MFS commands already implement the --cid-base option:

  • jsipfs files ls
  • jsipfs files stat

It also adds ?cid-base= query option to the following HTTP endpoints:

  • /api/v0/bitswap/wantlist
  • /api/v0/bitswap/stat
  • /api/v0/bitswap/unwant
  • /api/v0/block/put
  • /api/v0/block/stat
  • /api/v0/add
  • /api/v0/ls
  • /api/v0/object/new
  • /api/v0/object/get
  • /api/v0/object/put
  • /api/v0/object/stat
  • /api/v0/object/links
  • /api/v0/object/patch/append-data
  • /api/v0/object/patch/set-data
  • /api/v0/object/patch/add-link
  • /api/v0/object/patch/rm-link
  • /api/v0/pin/ls
  • /api/v0/pin/add
  • /api/v0/pin/rm
  • /api/v0/resolve

It adds a cidBase option to the following core functions:

  • resolve

@ghost ghost assigned alanshaw Sep 10, 2018
@ghost ghost added the status/in-progress In progress label Sep 10, 2018
@achingbrain

This comment has been minimized.

@alanshaw

This comment has been minimized.

@achingbrain

This comment has been minimized.

@kevina
Copy link

kevina commented Sep 20, 2018

P.R. for go-ipfs: ipfs/kubo#5464. Not that for many commands I did it the Cid base conversion client-side when possible.

I agree that for resolve it should be done on the server as the result is a path and not a CID.

@daviddias
Copy link
Member

Will this PR also default to base32 or is that a separate PR?

@daviddias daviddias added the P0 Critical: Tackled by core team ASAP label Nov 2, 2018
@alanshaw
Copy link
Member Author

alanshaw commented Nov 9, 2018

Will this PR also default to base32 or is that a separate PR?

@diasdavid that a separate PR

TODO:

Copy link
Member

@hugomrdias hugomrdias left a comment

Choose a reason for hiding this comment

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

LGTM

package.json Outdated Show resolved Hide resolved
@kevina
Copy link

kevina commented Nov 27, 2018

@alanshaw, I am not sure how high of a priority staying consist with go-ipfs is. If it is a high priority please note that @Stebalien has not signed off yet on how to handle --cid-base on the go-ipfs side, so it is unclear if we will end up supporting cid-base for HTTP requests or the exact semantics we will end up using.

@alanshaw
Copy link
Member Author

alanshaw commented Nov 29, 2018

@Stebalien can we get a firm decision on whether go-ipfs will support ?cid-base query string argument in the HTTP API as this PR is ready to merge (pending a rebase) and I had planned to include this in the 0.34 release 🔜

Thank you 😄!


For context: ipfs/kubo#5777 (comment)

Alan Shaw added 20 commits December 16, 2018 19:13
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
Alan Shaw added 5 commits December 16, 2018 20:13
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
@alanshaw alanshaw merged commit 6d46e2e into master Dec 17, 2018
@alanshaw alanshaw deleted the feat/cid-base-option branch December 17, 2018 10:19
@ghost ghost removed the status/in-progress In progress label Dec 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P0 Critical: Tackled by core team ASAP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants