@cryptotaxi247 / kubo / commits / 7dbdb0e81

Document cleanup and additional references

- Cleaned up the document. - Added additional references to documents. License: MIT Signed-off-by: Nitish Malhotra <nitish.malhotra@gmail.com>

nmalhotra committed Jan 14, 2019 at 21:53 UTC 7dbdb0e813c565532d5b0526d2b9cc4b367d0d5f
1 file changed +12 -12
docs/add-code-flow.md
+12 -12
@@ -1,8 +1,6 @@
1 # IPFS : The `Add` command demystified
2
3 -https://github.com/ipfs/go-ipfs/blob/v0.4.18/core/commands/add.go#L208-L213
4 -
5 -The goal of this document is to capture the code flow for adding a file (see the `coreapi` package) using the IPFS CLI, in the process exploring some datastructures and packages like `ipld.Node` (aka `dagnode`, `FSNode`, `MFS`, etc.
3 +The goal of this document is to capture the code flow for adding a file (see the `coreapi` package) using the IPFS CLI, in the process exploring some datastructures and packages like `ipld.Node` (aka `dagnode`), `FSNode`, `MFS`, etc.
4
5 **Try this yourself**
6 >
@@ -42,11 +40,11 @@ Within the function, a new `Adder` is created with the configured `Blockstore` a
40 - **[`adder.AddAllAndPin(files)`](https://github.com/ipfs/go-ipfs/blob/v0.4.18/core/coreunix/add.go#L403)** - *Entrypoint to the `Add` logic*
41 encapsulates a lot of the underlying functionality that will be investigated in the following sections.
42
45 - Our focus will be on the simplest case, a single file, handled by `Adder.addFileNode(path, file)` handled by `Adder.addFile(pathm files.File)`.
43 + Our focus will be on the simplest case, a single file, handled by `Adder.addFile(file files.File)`.
44
47 - - **[`adder.addFile(path, files.File)`](https://github.com/ipfs/go-ipfs/blob/v0.4.18/core/coreunix/add.go#L450)** - *Create the _DAG_ and add to `MFS`*
45 + - **[`adder.addFile(file files.File)`](https://github.com/ipfs/go-ipfs/blob/v0.4.18/core/coreunix/add.go#L450)** - *Create the _DAG_ and add to `MFS`*
46
49 - The `addFile(file)` method takes the data and converts it into a __DAG__ tree and adds the root of the tree in to the `MFS`.
47 + The `addFile(file)` method takes the data and converts it into a __DAG__ tree and adds the root of the tree into the `MFS`.
48
49 https://github.com/ipfs/go-ipfs/blob/v0.4.18/core/coreunix/add.go#L508-L521
50
@@ -80,18 +78,16 @@ Within the function, a new `Adder` is created with the configured `Blockstore` a
78
79 The node is then added as a child to the inner `UnixFS` directory using the `(BasicDirectory).AddChild()` method.
80
83 - > NOTE: This is not to be confused with the `directory.AddChild(filename, ipld.Node)`, as this operates on the `UnixFS` `BasicDirectory` object only.
81 + > NOTE: This is not to be confused with the `directory.AddChild(filename, ipld.Node)`, as this operates on the `UnixFS` `BasicDirectory` object.
82
83 - **[UnixFS] [`(BasicDirectory).AddChild(ctx, name, ipld.Node)`](https://github.com/ipfs/go-unixfs/blob/v1.1.16/io/directory.go#L137)** - *Add child to `BasicDirectory`*
84
87 - > IMPORTANT: It should be noted that the `BasicDirectory` struct of the `UnixFS` package, encasulates a node object of type `ProtoNode`, which is a different format from the `ipld.Node` we have been working on throughout this document.
85 + > IMPORTANT: It should be noted that the `BasicDirectory` object uses the `ProtoNode` type object which is an implementation of the `ipld.Node` interface, seen and used throughout this document. Ideally the `ipld.Node` should always be used, unless we need access tp specific functions from `ProtoNode` (like `Copy()`) that are not available in the interface.
86
87 This method first attempts to remove any old links (`ProtoNode.RemoveNodeLink(name)`) to the `ProtoNode` prior to adding a link to the newly added `ipld.Node`, using `ProtoNode.AddNodeLink(name, ipld.Node)`.
88
91 - - **[Merkledag] [`AddNodeLink()`](https://github.com/ipfs/go-merkledag/blob/v1.1.13/node.go#L99)**
89 + - **[Merkledag] [`AddNodeLink()`](https://github.com/ipfs/go-merkledag/blob/v1.1.15/node.go#L99)**
90
93 - **HELP: The go-merkledag version is supposed to v1.1.15 for this example, however that version has not been added to the [releases](https://github.com/ipfs/go-merkledag/releases)**
94 -
91 The `AddNodeLink()` method is where an `ipld.Link` is created with the `ipld.Node`'s `CID` and size in the `ipld.MakeLink(ipld.Node)` method, and is then appended to the `ProtoNode`'s links in the `ProtoNode.AddRawLink(name)` method.
92
93 - **[`adder.Finalize()`](https://github.com/ipfs/go-ipfs/blob/v0.4.18/core/coreunix/add.go#L200)** - *Fetch and return the __DAG__ **root** from the `MFS` and `UnixFS` directory*
@@ -100,4 +96,8 @@ Within the function, a new `Adder` is created with the configured `Blockstore` a
96
97 - **[`adder.PinRoot()`](https://github.com/ipfs/go-ipfs/blob/v0.4.18/core/coreunix/add.go#L171)** - *Pin all files under the `MFS` **root***
98
103 - The whole process ends with `PinRoot` recursively pinning all the files under the `MFS` **root**
\ No newline at end of file
99 + The whole process ends with `PinRoot` recursively pinning all the files under the `MFS` **root**
100 +
101 +# Also see
102 +1. https://github.com/ipfs/go-ipfs/#development
103 +2. [Concept document about files](https://github.com/ipfs/docs/issues/133)
\ No newline at end of file