From 269550bcbaf7779a4fdfe2b0eca075becce040e9 Mon Sep 17 00:00:00 2001 From: nmalhotra Date: Tue, 15 Jan 2019 21:03:50 -0500 Subject: [PATCH] Added link to doc in README.md - Fixed typo. - Moved concept document link to top of page. - Added link to this doc to README.md License: MIT Signed-off-by: Nitish Malhotra --- README.md | 1 + docs/add-code-flow.md | 17 ++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 1fb35a06a67..4dfb83806d3 100644 --- a/README.md +++ b/README.md @@ -403,6 +403,7 @@ Some places to get you started on the codebase: - libp2p: https://github.com/libp2p/go-libp2p - DHT: https://github.com/libp2p/go-libp2p-kad-dht - PubSub: https://github.com/libp2p/go-libp2p-pubsub +- [IPFS : The `Add` command demystified](https://github.com/ipfs/go-ipfs/tree/master/docs/add-code-flow.md) ### CLI, HTTP-API, Architecture Diagram diff --git a/docs/add-code-flow.md b/docs/add-code-flow.md index ba96cfea91f..a13c7177d40 100644 --- a/docs/add-code-flow.md +++ b/docs/add-code-flow.md @@ -2,6 +2,11 @@ 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. +## Concepts +- [Files](https://github.com/ipfs/docs/issues/133) + +--- + **Try this yourself** > > ``` @@ -28,9 +33,7 @@ The goal of this document is to capture the code flow for adding a file (see the > # Hello World > ``` ---- - -# Code Flow +## Code Flow **[`UnixfsAPI.Add()`](https://github.com/ipfs/go-ipfs/blob/v0.4.18/core/coreapi/unixfs.go#L31)** - *Entrypoint into the `Unixfs` package* @@ -82,7 +85,7 @@ Within the function, a new `Adder` is created with the configured `Blockstore` a - **[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`* - > 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. + > 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 to specific functions from `ProtoNode` (like `Copy()`) that are not available in the interface. 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)`. @@ -96,8 +99,4 @@ Within the function, a new `Adder` is created with the configured `Blockstore` a - **[`adder.PinRoot()`](https://github.com/ipfs/go-ipfs/blob/v0.4.18/core/coreunix/add.go#L171)** - *Pin all files under the `MFS` **root*** - The whole process ends with `PinRoot` recursively pinning all the files under the `MFS` **root** - -# Also see -1. https://github.com/ipfs/go-ipfs/#development -2. [Concept document about files](https://github.com/ipfs/docs/issues/133) \ No newline at end of file + The whole process ends with `PinRoot` recursively pinning all the files under the `MFS` **root** \ No newline at end of file