daemon: wire up fsrepo

This commit is contained in:
Łukasz Magiera 2019-07-10 19:10:19 +02:00
parent 1f8c3f4145
commit 2e8dfc759b
2 changed files with 16 additions and 9 deletions

View File

@ -6,8 +6,6 @@ import (
"gopkg.in/urfave/cli.v2" "gopkg.in/urfave/cli.v2"
"github.com/filecoin-project/go-lotus/api"
"github.com/filecoin-project/go-lotus/api/client"
"github.com/filecoin-project/go-lotus/build" "github.com/filecoin-project/go-lotus/build"
lcli "github.com/filecoin-project/go-lotus/cli" lcli "github.com/filecoin-project/go-lotus/cli"
"github.com/filecoin-project/go-lotus/daemon" "github.com/filecoin-project/go-lotus/daemon"
@ -22,11 +20,13 @@ func main() {
Name: "lotus", Name: "lotus",
Usage: "Filecoin decentralized storage network client", Usage: "Filecoin decentralized storage network client",
Version: build.Version, Version: build.Version,
Metadata: map[string]interface{}{ Flags: []cli.Flag{
"api": lcli.ApiConnector(func() api.API { &cli.StringFlag{
// TODO: get this from repo Name: "repo",
return client.NewRPC("http://127.0.0.1:1234/rpc/v0") EnvVars: []string{"LOTUS_PATH"},
}), Hidden: true,
Value: "~/.lotus", // TODO: Consider XDG_DATA_HOME
},
}, },
Commands: append(local, lcli.Commands...), Commands: append(local, lcli.Commands...),

View File

@ -23,11 +23,18 @@ var Cmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
ctx := context.Background() ctx := context.Background()
repo := repo.NewMemory(nil) r, err := repo.NewFS(cctx.String("repo"))
if err != nil {
return err
}
if err := r.Init(); err != nil && err != repo.ErrRepoExists {
return err
}
api, err := node.New(ctx, api, err := node.New(ctx,
node.Online(), node.Online(),
node.Repo(repo), node.Repo(r),
) )
if err != nil { if err != nil {
return err return err