sync wait --watch
This commit is contained in:
parent
4ad8d85b13
commit
ab4f051b83
12
cli/sync.go
12
cli/sync.go
@ -84,6 +84,12 @@ var syncStatusCmd = &cli.Command{
|
||||
var syncWaitCmd = &cli.Command{
|
||||
Name: "wait",
|
||||
Usage: "Wait for sync to be complete",
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "watch",
|
||||
Usage: "don't exit after node is synced",
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
napi, closer, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
@ -92,7 +98,7 @@ var syncWaitCmd = &cli.Command{
|
||||
defer closer()
|
||||
ctx := ReqContext(cctx)
|
||||
|
||||
return SyncWait(ctx, napi)
|
||||
return SyncWait(ctx, napi, cctx.Bool("watch"))
|
||||
},
|
||||
}
|
||||
|
||||
@ -234,7 +240,7 @@ var syncCheckpointCmd = &cli.Command{
|
||||
},
|
||||
}
|
||||
|
||||
func SyncWait(ctx context.Context, napi api.FullNode) error {
|
||||
func SyncWait(ctx context.Context, napi api.FullNode, watch bool) error {
|
||||
tick := time.Second / 4
|
||||
|
||||
lastLines := 0
|
||||
@ -311,7 +317,7 @@ func SyncWait(ctx context.Context, napi api.FullNode) error {
|
||||
|
||||
_ = target // todo: maybe print? (creates a bunch of line wrapping issues with most tipsets)
|
||||
|
||||
if time.Now().Unix()-int64(head.MinTimestamp()) < int64(build.BlockDelaySecs) {
|
||||
if !watch && time.Now().Unix()-int64(head.MinTimestamp()) < int64(build.BlockDelaySecs) {
|
||||
fmt.Println("\nDone!")
|
||||
return nil
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ var initCmd = &cli.Command{
|
||||
log.Info("Checking full node sync status")
|
||||
|
||||
if !cctx.Bool("genesis-miner") && !cctx.Bool("nosync") {
|
||||
if err := lcli.SyncWait(ctx, api); err != nil {
|
||||
if err := lcli.SyncWait(ctx, api, false); err != nil {
|
||||
return xerrors.Errorf("sync wait: %w", err)
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ var initRestoreCmd = &cli.Command{
|
||||
}
|
||||
|
||||
if !cctx.Bool("nosync") {
|
||||
if err := lcli.SyncWait(ctx, api); err != nil {
|
||||
if err := lcli.SyncWait(ctx, api, false); err != nil {
|
||||
return xerrors.Errorf("sync wait: %w", err)
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ var runCmd = &cli.Command{
|
||||
log.Info("Checking full node sync status")
|
||||
|
||||
if !cctx.Bool("nosync") {
|
||||
if err := lcli.SyncWait(ctx, nodeApi); err != nil {
|
||||
if err := lcli.SyncWait(ctx, nodeApi, false); err != nil {
|
||||
return xerrors.Errorf("sync wait: %w", err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user