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

Add CIDs for IPFS and Swarm #104

Merged
merged 4 commits into from
Jan 10, 2019
Merged

Add CIDs for IPFS and Swarm #104

merged 4 commits into from
Jan 10, 2019

Conversation

Arachnid
Copy link
Contributor

As discussed in multiformats/multiaddr#73 and offline.

@Arachnid
Copy link
Contributor Author

Arachnid commented Jan 3, 2019

Ping?

table.csv Outdated
@@ -447,3 +447,7 @@ leofcoin-pr, Leofcoin Peer Reputation, 0x83
torrent-info, Torrent file info field (bencoded), 0x7b
torrent-file, Torrent file (bencoded), 0x7c
ed25519-pub, Ed25519 public key, 0xed

CIDs,,
Copy link
Member

Choose a reason for hiding this comment

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

Maybe "content namespaces"?. We're not really defining new types of CIDs.

  1. ipld-ns: [/arbitrary/path]
  2. ipfs-ns: [/arbitrary/path]
  3. swarm-ns: [byte range?]

We could also merge #93 to allow arbitrary string paths (although we don't have to do it that way).

Basically, I'd like to make this as flexible as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you elaborate on what an IPLD NS would encode, as opposed to an IPFS-NS? Would it be a CID, or some other data format?

Copy link
Member

Choose a reason for hiding this comment

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

I'm just taking string paths and encoding them in a compact binary form.

  • /ipld/SomeStringCID/some/remaining/path -> <ipld-namespace-multicodec><binary-cid><path>
  • /ipfs/SomeStringCID/some/remaining/path -> <ipfs-namespace-multicodec><binary-cid><path>

So these will both be CIDs + Paths.

We need different namespaces because IPFS is built on top of IPLD. In IPFS, we' interpret the content as files and directories and the path a traversal through a directory tree. In IPLD we interpret the content as structured data and the path as a traversal through a JSON-like datastructure.


For the swarm namespace, I wrote [byte range?] as you may want to allow for a byte range in addition to the CID.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How are paths encoded, in this scheme?

Copy link
Member

Choose a reason for hiding this comment

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

As a string although we may want to length-prefix these strings.

Regardless, we can probably skip that for now. The important part here is to reserve these numbers. Regardless of what we say now, we'll probably change our minds when we actually try to prototype these.

Copy link
Member

Choose a reason for hiding this comment

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

(If you'd like to avoid the github round-trip, you can ping me on the #ipfs IRC channel, also #ipfs-dev:matrix.org. Unfortunately, we don't have an active multiformats channel.)

@Stebalien Stebalien requested a review from daviddias January 3, 2019 19:45
table.csv Outdated
@@ -447,3 +447,8 @@ leofcoin-pr, Leofcoin Peer Reputation, 0x83
torrent-info, Torrent file info field (bencoded), 0x7b
torrent-file, Torrent file (bencoded), 0x7c
ed25519-pub, Ed25519 public key, 0xed

Content Namespaces,,
ipld-ns, IPLD CID and optional path, 0xee
Copy link
Member

Choose a reason for hiding this comment

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

We can be a bit more abstract here and just say "IPLD path", "IPFS path", and "Swarm path" instead of specifying the precise format for the argument. That is, we know we'll use <namespace-codec><stuff...> but we can decide on <stuff...> later.

For example, swarm probably won't want arbitrary paths (it doesn't support directories, as far as I know. Instead, it will at most want byte ranges (e.g., /swarm/CID or /swarm/CID/0..200).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Swarm does support paths, in a similar fashion to IPFS, by storing manifest files.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, got it. I just saw the docs on Swarm-Hash and assumed it was blob-only.

Copy link
Member

Choose a reason for hiding this comment

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

In that case, I there is some value in trying to standardize on a binary format for content paths up-front. My thinking was just <namespace-codec (varint)><binary-cid><string-path> (where <string-path> is an optional /a/b/c...). Thoughts?

(we can also discuss this in a separate issue if you'd like).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seems reasonable. I liked the suggestion of reserving / as the multicodec for "path component". I think this'd be best discussed in its own issue, though.

@Stebalien Stebalien merged commit 2f25673 into multiformats:master Jan 10, 2019
@whyrusleeping
Copy link
Member

@Stebalien I just noticed that the 0xf0 codec is already in use. Not sure what should be done about that

Stebalien added a commit that referenced this pull request Jan 18, 2019
@Stebalien
Copy link
Member

I had one job... I guess it's time to give in to our robot overlords.

Fix and CI in: #113

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.

3 participants