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

WIP: IPLD spec #37

Merged
merged 38 commits into from
Feb 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a98020f
ipld spec
jbenet Nov 8, 2015
74bc794
link to paths issue
jbenet Nov 8, 2015
37c662a
CR fixes
jbenet Nov 22, 2015
878cb31
IPLD: precisions about canonical format
mildred Jan 8, 2016
5fc71ab
Merge pull request #63 from mildred/ipld-spec-canonical-repr
jbenet Jan 9, 2016
2dd135e
Rename Merkle links key from mlink to link
mildred Jan 10, 2016
0381888
Relationship with Protocol Buffers legacy IPFS node format
mildred Jan 7, 2016
bc2050c
Talk about escaping keys in merkle-paths
mildred Jan 8, 2016
89dd82d
Move (and update) section about protobuf compat to separate file
mildred Jan 8, 2016
5b97e14
Change protocol buffer compatibility format.
mildred Jan 10, 2016
691b2b0
Fix traversal example in ipld-spec
findkiko Jan 13, 2016
8f31fa1
Merge pull request #1 from findkiko/ipld_example_fix
findkiko Jan 13, 2016
4066034
Merge pull request #67 from findkiko/ipld-spec
jbenet Jan 13, 2016
33ca56e
IPLD Protocol Buffer compatibility: fix errors
mildred Feb 9, 2016
1ab421b
Only keep first alternative.
mildred Feb 9, 2016
d1ceeb3
Do not make use of escaping
mildred Feb 9, 2016
6f5a601
Replace link key by @link
mildred Feb 9, 2016
6e69d61
Merge pull request #64 from mildred/ipld-spec-link-insteadof-mlink
jbenet Feb 11, 2016
c845223
Minor wording tweaks
mildred Feb 11, 2016
33e48ff
Describe CBOR tagging
mildred Jan 8, 2016
9c22d9a
CBOR tagging: simplify tagging and remove key escapes management
mildred Jan 10, 2016
ccadf1d
Simple CBOR format
mildred Feb 9, 2016
7619b64
Change wording and don't store an empty map when links have no attrib…
mildred Feb 10, 2016
1a3f4a9
Don't require the tag to be followed by an array if there are no prop…
mildred Feb 10, 2016
dfb8903
Minor edits
mildred Feb 11, 2016
a15797a
Separate filesystem merkle-path from IPLD merkle-path
Jan 7, 2016
24bd624
Add note about uses of filesystem merkle-paths
mildred Jan 8, 2016
ec26862
Talk about escaping keys in merkle-paths
mildred Jan 8, 2016
201a0d4
Consideration about key escaping
mildred Jan 8, 2016
e1a1071
Go back to a single merkle-link with two separators
mildred Jan 8, 2016
5062f8c
IPLD merkle paths: typo fixes
mildred Jan 9, 2016
bb5ad86
ipld merkle paths: clarify the usage scope
mildred Jan 9, 2016
213c7ed
New description of merkle-paths
mildred Feb 11, 2016
6734c93
Merge pull request #61 from mildred/ipld-cbor-tagging
jbenet Feb 12, 2016
2ee6909
Improve spec on paths
mildred Feb 12, 2016
b1d4bd7
Merge pull request #62 from mildred/ipld-spec-linkprop2
jbenet Feb 12, 2016
ffa001e
Remove named links section (but leave the possibility open)
mildred Feb 12, 2016
fc38955
Merge pull request #59 from mildred/ipld-spec
jbenet Feb 12, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions merkledag/ipld-compat-protobuf.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# IPLD conversion with Protocol Buffer legacy IPFS node format

IPLD has a known conversion with the legacy Protocol Buffers format in order for new IPLD objects to interact with older protocol buffer objects.

## Detecting the format in use

The format is encapsulated after two multicodec headers. The first have the codec path `/mdagv1` and can be used to detect whether IPLD objects are transmitted or just legacy protocol buffer messages.

The second multicodec header is used to detect the actual format in which the IPLD object is encoded:

- `/protobuf/msgio`: is the encapsulation for protocol buffer message
- `/json`: is the encapsulation for JSON encoding
- `/cbor`: is the encapsulation for CBOR encoding

For example, a protocol buffer object encapsulated in a multicodec header would start with "`\x08/mdagv1\n\x10/protobuf/msgio\n`" corresponding to the bytes :

08 2f 6d 64 61 67 76 31 0a
10 2f 70 72 6f 74 6f 62 75 66 2f 6d 73 67 69 6f 0a

A JSON encoded object would start with "`\x08/mdagv1\n\x06/json\n`" and a CBOR encoded object would start with "`\x08/mdagv1\n\x06/cbor\n`".


## Description of the legacy protocol buffers format

This format is defined with the Protocol Buffers syntax as:

message PBLink {
optional bytes Hash = 1;
optional string Name = 2;
optional uint64 Tsize = 3;
}

message PBNode {
repeated PBLink Links = 2;
optional bytes Data = 1;
}

## Conversion to IPLD model

The conversion to the IPLD data model MUST be convertible back to protocol buffers, resulting in an identical byte stream (so the hash corresponds). This implies that ordering and duplicate links must be preserved in some way. As such, they are stored in an array and not in a map indexed by their name.

There is a canonical form which is described below:

{
"data": "<Data>",
"links": [
{
"@link": "/ipfs/<Links[0].Hash.(base58)>",
"name": "<Links[0].Name>",
"size": <Links[0].Tsize>
},
{
"@link": "/ipfs/<Links[1].Hash.(base58)>",
"name": "<Link[1].Name>",
"size": <Links[1].Tsize>
},
{
"@link": "/ipfs/<Links[2].Hash.(base58)>",
"name": "<Links[2].Name>",
"size": <Links[2].Tsize>
},
...
]
}

The main object contains:

- A `data` key containing the binary data string
- A `links` array containing links in the correct order

Each link consists of:

- A `@link` key containing the path to the destination document (Using the `/ipfs/` prefix)
- A `name` key containing the link name (a text string)
- A `size` unsigned integer containing the link size as stored in the Protocol Buffer object

Implementations are free to add any other top level key they need. In particular it may be interesting to access the links indexed by their name. This is a purely optional feature and additional keys cannot possibly be encoded back to the protonal Protocol Buffer format.
Loading