Skip to content

Commit

Permalink
Added link to doc in README.md
Browse files Browse the repository at this point in the history
- 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 <nitish.malhotra@gmail.com>
  • Loading branch information
nmalhotra committed Jan 16, 2019
1 parent 7dbdb0e commit 269550b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 8 additions & 9 deletions docs/add-code-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
>
> ```
Expand All @@ -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*

Expand Down Expand Up @@ -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)`.

Expand All @@ -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)
The whole process ends with `PinRoot` recursively pinning all the files under the `MFS` **root**

0 comments on commit 269550b

Please sign in to comment.