Skip to content

Commit

Permalink
refactor: code layout v2 (#3596)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ignacio Corderi committed Oct 26, 2019
1 parent fb13acc commit b926dad
Show file tree
Hide file tree
Showing 530 changed files with 1,930 additions and 1,894 deletions.
16 changes: 12 additions & 4 deletions .gitignore
@@ -1,25 +1,33 @@
go-filecoin
!cmd/go-filecoin
!internal/app/go-filecoin

.task
.idea
*.coverprofile
*.out
*.so
.idea
gengen/gengen
gengen/gensetup

fixtures/test
!fixtures/test/.gitkeep
fixtures/live
!fixtures/live/.gitkeep

// Tools
gengen/gengen
gengen/gensetup
tools/fast/bin/localnet
tools/faucet/faucet
tools/aggregator/aggregator
tools/genesis-file-server/genesis-file-server
tools/migration/go-filecoin-migrate
tools/prerelease-tool/prerelease-tool

**/paramcache
**/*.h
**/*.a
**/*.pc

// IDE (vscode)
.vscode
.vscode
debug.test
4 changes: 2 additions & 2 deletions CODEWALK.md
Expand Up @@ -649,11 +649,11 @@ Stats are exported for consumption via [Prometheus](https://prometheus.io/) and
#### Metrics

go-filecoin can be configured to collect and export metrics to Prometheus via the `MetricsConfig`.
The details of this can be found inside the [`config/`](https://godoc.org/github.com/filecoin-project/go-filecoin/config#ObservabilityConfig) package.
The details of this can be found inside the [`config/`](https://godoc.org/github.com/filecoin-project/go-filecoin/internal/pkg/config#ObservabilityConfig) package.
To view metrics from your filecoin node using the default configuration options set the `prometheusEnabled` value to `true`, start the filecoin daemon, then visit `localhost:9400/metrics` in your web-browser.

#### Tracing

go-filecoin can be configured to collect and export traces to Jaeger via the `TraceConfig`.
The details of this can be found inside the [`config/`](https://godoc.org/github.com/filecoin-project/go-filecoin/config#ObservabilityConfig) package.
The details of this can be found inside the [`config/`](https://godoc.org/github.com/filecoin-project/go-filecoin/internal/pkg/config#ObservabilityConfig) package.
To collect traces from your filecoin node using the default configuration options set the `jaegerTracingEnabled` value to `true`, start the filecoin daemon, then follow the [Jaeger Getting](https://www.jaegertracing.io/docs/1.11/getting-started/#all-in-one) started guide.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -306,7 +306,7 @@ import (
ipld "github.com/ipfs/go-ipld-format"
"github.com/stretchr/testify/assert"

"github.com/filecoin-project/go-filecoin/testhelpers"
"github.com/filecoin-project/go-filecoin/types"
"github.com/filecoin-project/go-filecoin/internal/pkg/testhelpers"
"github.com/filecoin-project/go-filecoin/internal/pkg/types"
)
```
25 changes: 0 additions & 25 deletions actor/actor_encoding_gen.go

This file was deleted.

20 changes: 0 additions & 20 deletions actor/builtin/initactor/initactor_encoding_gen.go

This file was deleted.

25 changes: 0 additions & 25 deletions actor/builtin/miner/miner_encoding_gen.go

This file was deleted.

20 changes: 0 additions & 20 deletions actor/builtin/paymentbroker/paymentbroker_encoding_gen.go

This file was deleted.

20 changes: 0 additions & 20 deletions actor/builtin/storagemarket/storagemarket_encoding_gen.go

This file was deleted.

25 changes: 0 additions & 25 deletions block/block_encoding_gen.go

This file was deleted.

7 changes: 7 additions & 0 deletions build/flags/flags.go
@@ -0,0 +1,7 @@
package flags

// GitCommit is the current git commit, this is injected through ldflags.
var GitCommit string

// GitRoot is the git root, this is injected through ldflags.
var GitRoot string
17 changes: 17 additions & 0 deletions build/internal/helpers/gitroot.go
@@ -0,0 +1,17 @@
package helpers

import (
"os/exec"
"strings"
)

// GetGitRoot return the project root joined with any path fragments
func GetGitRoot() string {
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
out, err := cmd.CombinedOutput()
if err != nil {
panic("could not find git root")
}

return strings.Trim(string(out), "\n")
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,10 +1,10 @@
package version_test

import (
"github.com/filecoin-project/go-filecoin/util/version"
"github.com/filecoin-project/go-filecoin/build/internal/version"
"testing"

tf "github.com/filecoin-project/go-filecoin/testhelpers/testflags"
tf "github.com/filecoin-project/go-filecoin/internal/pkg/testhelpers/testflags"
"github.com/stretchr/testify/assert"
)

Expand Down
28 changes: 18 additions & 10 deletions build/main.go
Expand Up @@ -13,7 +13,8 @@ import (
"sync"
"time"

"github.com/filecoin-project/go-filecoin/util/version"
"github.com/filecoin-project/go-filecoin/build/internal/helpers"
"github.com/filecoin-project/go-filecoin/build/internal/version"
)

var lineBreak = "\n"
Expand Down Expand Up @@ -167,9 +168,7 @@ func forceBuildFC() {
log.Println("Force building go-filecoin...")

runCmd(cmd([]string{
"go", "build",
"-ldflags", fmt.Sprintf("-X github.com/filecoin-project/go-filecoin/flags.Commit=%s", getCommitSha()),
"-a", "-v", "-o", "go-filecoin", ".",
"bash", "-c", fmt.Sprintf("go build %s -a -v -o go-filecoin .", flags()),
}...))
}

Expand Down Expand Up @@ -243,13 +242,18 @@ func generateGenesis() {
}...))
}

func flags() string {
return fmt.Sprintf("-ldflags=github.com/filecoin-project/go-filecoin=\"%s\"", strings.Join([]string{
fmt.Sprintf("-X github.com/filecoin-project/go-filecoin/build/flags.GitRoot=%s", helpers.GetGitRoot()),
fmt.Sprintf("-X github.com/filecoin-project/go-filecoin/build/flags.GitCommit=%s", getCommitSha()),
}, " "))
}

func buildFilecoin() {
log.Println("Building go-filecoin...")

runCmd(cmd([]string{
"go", "build",
"-ldflags", fmt.Sprintf("-X github.com/filecoin-project/go-filecoin/flags.Commit=%s", getCommitSha()),
"-v", "-o", "go-filecoin", ".",
"bash", "-c", fmt.Sprintf("go build %s -v -o go-filecoin .", flags()),
}...))
}

Expand Down Expand Up @@ -286,7 +290,9 @@ func buildPrereleaseTool() {
func install() {
log.Println("Installing...")

runCmd(cmd("go", "install", "-ldflags", fmt.Sprintf("-X github.com/filecoin-project/go-filecoin/flags.Commit=%s", getCommitSha())))
runCmd(cmd(
"bash", "-c", fmt.Sprintf("go install %s", flags()),
))
}

// test executes tests and passes along all additional arguments to `go test`.
Expand All @@ -300,8 +306,10 @@ func test(userArgs ...string) {
}

begin := time.Now()
runCmd(cmd(fmt.Sprintf("go test %s %s",
strings.Replace(packages, "\n", " ", -1), strings.Join(userArgs, " "))))
runCmd(cmd(
"bash", "-c", fmt.Sprintf("go test %s %s",
strings.Replace(packages, "\n", " ", -1),
strings.Join(userArgs, " "))))
end := time.Now()
log.Printf("Tests finished in %.1f seconds\n", end.Sub(begin).Seconds())
}
Expand Down
19 changes: 19 additions & 0 deletions build/project/project.go
@@ -0,0 +1,19 @@
package project

import (
"path/filepath"

"github.com/filecoin-project/go-filecoin/build/flags"
"github.com/filecoin-project/go-filecoin/build/internal/helpers"
)

// Root return the project root joined with any path fragments
func Root(paths ...string) string {
if flags.GitRoot == "" {
// load the root if flag not present
// Note: in some environments (i.e. IDE's) it wont be present
flags.GitRoot = helpers.GetGitRoot()
}
allPaths := append([]string{flags.GitRoot}, paths...)
return filepath.Join(allPaths...)
}
16 changes: 8 additions & 8 deletions commands/actor.go → cmd/go-filecoin/actor.go
Expand Up @@ -6,14 +6,14 @@ import (
"reflect"
"strings"

"github.com/filecoin-project/go-filecoin/actor"
"github.com/filecoin-project/go-filecoin/actor/builtin/account"
"github.com/filecoin-project/go-filecoin/actor/builtin/initactor"
"github.com/filecoin-project/go-filecoin/actor/builtin/miner"
"github.com/filecoin-project/go-filecoin/actor/builtin/paymentbroker"
"github.com/filecoin-project/go-filecoin/actor/builtin/storagemarket"
"github.com/filecoin-project/go-filecoin/exec"
"github.com/filecoin-project/go-filecoin/types"
"github.com/filecoin-project/go-filecoin/internal/pkg/actor"
"github.com/filecoin-project/go-filecoin/internal/pkg/actor/builtin/account"
"github.com/filecoin-project/go-filecoin/internal/pkg/actor/builtin/initactor"
"github.com/filecoin-project/go-filecoin/internal/pkg/actor/builtin/miner"
"github.com/filecoin-project/go-filecoin/internal/pkg/actor/builtin/paymentbroker"
"github.com/filecoin-project/go-filecoin/internal/pkg/actor/builtin/storagemarket"
"github.com/filecoin-project/go-filecoin/internal/pkg/exec"
"github.com/filecoin-project/go-filecoin/internal/pkg/types"

"github.com/ipfs/go-cid"
"github.com/ipfs/go-ipfs-cmdkit"
Expand Down
Expand Up @@ -8,9 +8,9 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/filecoin-project/go-filecoin/commands"
th "github.com/filecoin-project/go-filecoin/testhelpers"
tf "github.com/filecoin-project/go-filecoin/testhelpers/testflags"
"github.com/filecoin-project/go-filecoin/cmd/go-filecoin"
th "github.com/filecoin-project/go-filecoin/internal/pkg/testhelpers"
tf "github.com/filecoin-project/go-filecoin/internal/pkg/testhelpers/testflags"
)

func TestActorDaemon(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions commands/address.go → cmd/go-filecoin/address.go
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/ipfs/go-ipfs-files"
"github.com/pkg/errors"

"github.com/filecoin-project/go-filecoin/address"
"github.com/filecoin-project/go-filecoin/types"
"github.com/filecoin-project/go-filecoin/internal/pkg/address"
"github.com/filecoin-project/go-filecoin/internal/pkg/types"
)

var walletCmd = &cmds.Command{
Expand Down
Expand Up @@ -10,10 +10,10 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/filecoin-project/go-filecoin/address"
"github.com/filecoin-project/go-filecoin/fixtures"
th "github.com/filecoin-project/go-filecoin/testhelpers"
tf "github.com/filecoin-project/go-filecoin/testhelpers/testflags"
"github.com/filecoin-project/go-filecoin/internal/pkg/address"
th "github.com/filecoin-project/go-filecoin/internal/pkg/testhelpers"
tf "github.com/filecoin-project/go-filecoin/internal/pkg/testhelpers/testflags"
)

func TestAddrsNewAndList(t *testing.T) {
Expand Down
File renamed without changes.

0 comments on commit b926dad

Please sign in to comment.