From a2c1f3f158d4965cd20daaf5737061e318c74548 Mon Sep 17 00:00:00 2001 From: Mikeal Rogers Date: Fri, 21 Sep 2018 14:29:44 -0700 Subject: [PATCH 1/3] initial: wip draft spec skeleton. --- SPEC.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 SPEC.md diff --git a/SPEC.md b/SPEC.md new file mode 100644 index 0000000..76d6b56 --- /dev/null +++ b/SPEC.md @@ -0,0 +1,33 @@ +# Draft IPLD Unixfs Spec + +## Basic Structure + +A Unixfs is either a file or a directory. + +The top level IPLD object has at least two fields: `type` and `data` +and maybe a few other such as a version string or a set of flags. + +The `type` field is either `file` or `dir`. + +## IPLD `file` + +A file object has the following fields. + + - `type`: String with value of `'file'`. + - `data`: TODO: Define structure for file content data. + - `size`: Integer. Cumulative size of `data`. + +The `type` field must be set to `file`. + +## IPLD `dir` + +A directory object represents a directory. + +The key of the map is a filename and is a CBOR text string encoded in UTF-8. +The value of the map is another CBOR map with the following standard fields: + + - `type`: String with value of `'dir'`. + - `data`: TODO: Define structure for directory content data. + - `size`: Integer. Cumulative size of all directories and files in `data`. + +The `type` field set to `dir`. From dc1949a40164377197bc8fb66ed444fa7f858d9c Mon Sep 17 00:00:00 2001 From: Mikeal Rogers Date: Fri, 21 Sep 2018 15:01:05 -0700 Subject: [PATCH 2/3] initial: file-data definition. --- SPEC.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/SPEC.md b/SPEC.md index 76d6b56..b17c135 100644 --- a/SPEC.md +++ b/SPEC.md @@ -14,11 +14,31 @@ The `type` field is either `file` or `dir`. A file object has the following fields. - `type`: String with value of `'file'`. - - `data`: TODO: Define structure for file content data. + - `data`: Array of `file-data`. - `size`: Integer. Cumulative size of `data`. The `type` field must be set to `file`. +### `file-data` + +File data is an Array. Each element is an Array with only 2 elements (Tuple). + + - 0: Array. Tuple containing two integers, the `start` and `end` offsets of the content. + - 0: Integer: start offset. + - 1: Integer: end offset. + - 1: Link. Either a `raw` link or a link to another node formatted as `file-data`. + +```javascript +[ + [ [0, 1024], Link ], + [ [1025, 1089], Link ] +] +``` + +Implementations are encouraged to use nested `file-data` array nodes through links for files +with many chunks in order to limit the size of the serialized node. No strict boundary is +set but it is typical to try and limit node size to less than one megabyte. + ## IPLD `dir` A directory object represents a directory. From 4113dd60eb71b86dedf4048ed949c966a306b1d2 Mon Sep 17 00:00:00 2001 From: Mikeal Rogers Date: Thu, 4 Oct 2018 10:50:52 -0700 Subject: [PATCH 3/3] fix: using length rather than ending offset --- SPEC.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SPEC.md b/SPEC.md index b17c135..c9f5fab 100644 --- a/SPEC.md +++ b/SPEC.md @@ -23,15 +23,15 @@ The `type` field must be set to `file`. File data is an Array. Each element is an Array with only 2 elements (Tuple). - - 0: Array. Tuple containing two integers, the `start` and `end` offsets of the content. + - 0: Array. Tuple containing two integers, the `start` and `length` offsets of the content. - 0: Integer: start offset. - - 1: Integer: end offset. + - 1: Integer: length of part(s). - 1: Link. Either a `raw` link or a link to another node formatted as `file-data`. ```javascript [ [ [0, 1024], Link ], - [ [1025, 1089], Link ] + [ [1025, 1002], Link ] ] ```