Skip to content

Commit

Permalink
Merge pull request #428 from TRON-US/v1.0.4-release
Browse files Browse the repository at this point in the history
v1.0.4 release
  • Loading branch information
taiyangc authored Mar 16, 2020
2 parents 6deeb22 + 990ce19 commit 980c053
Show file tree
Hide file tree
Showing 35 changed files with 1,975 additions and 348 deletions.
117 changes: 117 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ contracts.

- [Install](#install)
- [System Requirements](#system-requirements)
- [Build from Source](#build-from-source)
- [MacOS](#macos)
- [Linux VM](#linux-vm)
- [Docker](#docker)
- [Usage](#usage)
- [Getting Started](#getting-started)
- [Some things to try](#some-things-to-try)
Expand Down Expand Up @@ -56,6 +60,119 @@ Start the BTFS Daemon
$ btfs daemon
```

## Build from Source

### MacOS

Clone the go-btfs repository
```
$ git clone https://github.com/TRON-US/go-btfs
```

Navigate to the go-btfs directory and run `make install`.
```
$ cd go-btfs
$ make install
```

A successful make install outputs something like:
```
$ make install
go: downloading github.com/tron-us/go-btfs-common v0.2.28
go: extracting github.com/tron-us/go-btfs-common v0.2.28
go: finding github.com/tron-us/go-btfs-common v0.2.28
go version go1.13.1 darwin/amd64
bin/check_go_version 1.13
bash patching.sh
go install "-asmflags=all='-trimpath='" "-gcflags=all='-trimpath='" -ldflags="-X "github.com/TRON-US/go-btfs".CurrentCommit=e4848946d" ./cmd/btfs
```

Afterwards, run `btfs init` and `btfs daemon` to initialize and start the daemon.

### Linux VM

Developers wishing to run a BTFS daemon on a Linux VM should first set up the environment. On an AWS EC2 Linux machine for example, it would be helpful to first install the following tools and dependencies:
```
$ sudo yum update // Installs general updates for Linux
$ sudo yum install git // Lets you git clone the go-btfs repository
$ sudo yum install patch // Required for building from source
$ sudo yum install gcc // Required for building from source
```

Building BTFS from source requires Go 1.13 or higher. To install from the terminal:
```
$ cd /tmp
$ GO_PACKAGE=go1.13.linux-amd64.tar.gz
$ wget https://golang.org/dl/$GO_PACKAGE
$ sudo tar -xvf $GO_PACKAGE
$ sudo mv go /usr/local
$ sudo rm $GO_PACKAGE
```

Navigate back to root directory and set the Go Path in the environment variables:
```
$ export GOPATH=${HOME}/go
$ export PATH=$PATH:/usr/local/go/bin
$ export PATH=$PATH:$GOPATH/bin
$ export GO111MODULE=on
```

Verify the Go version is 1.13 or higher:
```
$ go version
```

Navigate to the go-btfs directory and run `make install`.
```
$ cd go-btfs
$ make install
```

Afterwards, run `btfs init` and `btfs daemon` to initialize and start the daemon. To re-initialize a new pair of keys, you can shut down the daemon first via `btfs shutdown`. Then run `rm -r .btfs` and `btfs init` again.

### Docker

Developers also have the option to build a BTFS daemon within a Docker container. After cloning the go-btfs repository, navigate into the go-btfs directory. This is where the Dockerfile is located. Build the docker image:
```
$ cd go-btfs
$ docker image build -t btfs_docker . // Builds the docker image and tags "btfs_docker" as the name
```

A successful build should have an output like:
```
Sending build context to Docker daemon 2.789MB
Step 1/37 : FROM golang:1.13-stretch
---> 4fe257ac564c
Step 2/37 : MAINTAINER TRON-US <[email protected]>
---> Using cache
---> 02409001f528
...
Step 37/37 : CMD ["daemon", "--migrate=true"]
---> Running in 3660f91dce94
Removing intermediate container 3660f91dce94
---> b4e1523cf264
Successfully built b4e1523cf264
Successfully tagged btfs_docker:latest
```

Start the container based on the new image. Starting the container also initializes and starts the BTFS daemon.
```
$ docker container run --publish 5001:8080 --detach --name btfs1 btfs_docker
```

The CLI flags are as such:

* `--publish` asks Docker to forward traffic incoming on the host’s port 5001, to the container’s port 8080.
* `--detach` asks Docker to run this container in the background.
* `--name` specifies a name with which you can refer to your container in subsequent commands, in this case btfs1.

Execute commands within the docker container:
```
docker exec CONTAINER btfs add chunker=reed-solomon FILE
```

## Usage

```
Expand Down
3 changes: 2 additions & 1 deletion cmd/btfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
// Spin jobs in the background
spin.Analytics(cctx.ConfigRoot, node, version.CurrentVersionNumber, hValue)
spin.Hosts(node)
spin.Settings(node)

// Give the user some immediate feedback when they hit C-c
go func() {
Expand Down Expand Up @@ -550,6 +549,7 @@ func serveHTTPApi(req *cmds.Request, cctx *oldcmds.Context) (<-chan error, error
apiMaddr = apiLis.Multiaddr()
fmt.Printf("API server listening on %s\n", apiMaddr)
fmt.Printf("WebUI: http://%s/webui\n", apiLis.Addr())
//fmt.Printf("HostUI: http://%s/hostui\n", apiLis.Addr())
listeners = append(listeners, apiLis)
}

Expand All @@ -568,6 +568,7 @@ func serveHTTPApi(req *cmds.Request, cctx *oldcmds.Context) (<-chan error, error
corehttp.CheckVersionOption(),
corehttp.CommandsOption(*cctx),
corehttp.WebUIOption,
//corehttp.HostUIOption,
gatewayOpt,
corehttp.VersionOption(),
defaultMux("/debug/vars"),
Expand Down
1 change: 1 addition & 0 deletions cmd/ipfswatch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func run(ipfsPath, watchPath string) error {
var opts = []corehttp.ServeOption{
corehttp.GatewayOption(true, "/btfs", "/btns"),
corehttp.WebUIOption,
//corehttp.HostUIOption,
corehttp.CommandsOption(cmdCtx(node, ipfsPath)),
}
proc.Go(func(p process.Process) {
Expand Down
5 changes: 5 additions & 0 deletions core/commands/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ func TestCommands(t *testing.T) {
"/guard",
"/guard/test",
"/guard/test/send-challenges",
"/wallet",
"/wallet/init",
"/wallet/balance",
"/wallet/withdraw",
"/wallet/deposit",
}

cmdSet := make(map[string]struct{})
Expand Down
1 change: 1 addition & 0 deletions core/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ var rootSubcommands = map[string]*cmds.Command{
"storage": StorageCmd,
"metadata": MetadataCmd,
"guard": GuardCmd,
"wallet": WalletCmd,
//"update": ExternalBinary(),
}

Expand Down
Loading

0 comments on commit 980c053

Please sign in to comment.