storageminer: Wait for sync

This commit is contained in:
Łukasz Magiera
2019-12-04 01:25:18 +01:00
parent 3c271db802
commit 6467a982bc
3 changed files with 77 additions and 52 deletions
+17 -9
View File
@@ -80,6 +80,23 @@ var initCmd = &cli.Command{
return xerrors.Errorf("fetching proof parameters: %w", err)
}
log.Info("Trying to connect to full node RPC")
api, closer, err := lcli.GetFullNodeAPI(cctx) // TODO: consider storing full node address in config
if err != nil {
return err
}
defer closer()
ctx := lcli.ReqContext(cctx)
log.Info("Checking full node sync status")
if !cctx.Bool("genesis-miner") {
if err := lcli.SyncWait(ctx, api); err != nil {
return xerrors.Errorf("sync wait: %w", err)
}
}
log.Info("Checking if repo exists")
repoPath := cctx.String(FlagStorageRepo)
@@ -96,15 +113,6 @@ var initCmd = &cli.Command{
return xerrors.Errorf("repo at '%s' is already initialized", cctx.String(FlagStorageRepo))
}
log.Info("Trying to connect to full node RPC")
api, closer, err := lcli.GetFullNodeAPI(cctx) // TODO: consider storing full node address in config
if err != nil {
return err
}
defer closer()
ctx := lcli.ReqContext(cctx)
log.Info("Checking full node version")
v, err := api.Version(ctx)
+12
View File
@@ -35,6 +35,10 @@ var runCmd = &cli.Command{
Usage: "Enable use of GPU for mining operations",
Value: true,
},
&cli.BoolFlag{
Name: "nosync",
Usage: "Don't check full-node sync status",
},
},
Action: func(cctx *cli.Context) error {
if err := build.GetParams(true, false); err != nil {
@@ -61,6 +65,14 @@ var runCmd = &cli.Command{
return xerrors.Errorf("lotus-daemon API version doesn't match: local: ", api.Version{APIVersion: build.APIVersion})
}
log.Info("Checking full node sync status")
if !cctx.Bool("nosync") {
if err := lcli.SyncWait(ctx, nodeApi); err != nil {
return xerrors.Errorf("sync wait: %w", err)
}
}
storageRepoPath := cctx.String(FlagStorageRepo)
r, err := repo.NewFS(storageRepoPath)
if err != nil {