diff --git a/cli/dump_test.go b/cli/dump_test.go index fb2f24389..5beb692e6 100644 --- a/cli/dump_test.go +++ b/cli/dump_test.go @@ -40,17 +40,14 @@ func TestDBRestore(t *testing.T) { // First 15 blocks. e.Run(t, append(baseArgs, "--count", "15")...) - // Invalid skips. - e.RunWithError(t, append(baseArgs, "--count", "10", "--skip", "14")...) - e.RunWithError(t, append(baseArgs, "--count", "10", "--skip", "16")...) // Big count. - e.RunWithError(t, append(baseArgs, "--count", "1000", "--skip", "15")...) + e.RunWithError(t, append(baseArgs, "--count", "1000")...) // Continue 15..25 - e.Run(t, append(baseArgs, "--count", "10", "--skip", "15")...) + e.Run(t, append(baseArgs, "--count", "10")...) // Continue till end. - e.Run(t, append(baseArgs, "--skip", "25")...) + e.Run(t, baseArgs...) // Dump and compare. dumpPath := path.Join(tmpDir, "testdump.acc") diff --git a/cli/server/server.go b/cli/server/server.go index 73416907e..73dc32cfa 100644 --- a/cli/server/server.go +++ b/cli/server/server.go @@ -52,10 +52,6 @@ func NewCommands() []cli.Command { var cfgCountInFlags = make([]cli.Flag, len(cfgWithCountFlags)) copy(cfgCountInFlags, cfgWithCountFlags) cfgCountInFlags = append(cfgCountInFlags, - cli.UintFlag{ - Name: "skip, s", - Usage: "number of blocks to skip (default: 0)", - }, cli.StringFlag{ Name: "in, i", Usage: "Input file (stdin if not given)", @@ -219,7 +215,6 @@ func restoreDB(ctx *cli.Context) error { return cli.NewExitError(err, 1) } count := uint32(ctx.Uint("count")) - skip := uint32(ctx.Uint("skip")) var inStream = os.Stdin if in := ctx.String("in"); in != "" { @@ -251,6 +246,10 @@ func restoreDB(ctx *cli.Context) error { return cli.NewExitError(fmt.Errorf("expected height: %d, dump starts at %d", chain.BlockHeight()+1, start), 1) } + } + + var skip uint32 + if chain.BlockHeight() != 0 { skip = chain.BlockHeight() + 1 - start } @@ -264,6 +263,11 @@ func restoreDB(ctx *cli.Context) error { if count == 0 { count = allBlocks - skip } + log.Info("initialize restore", + zap.Uint32("start", start), + zap.Uint32("height", chain.BlockHeight()), + zap.Uint32("skip", skip), + zap.Uint32("count", count)) gctx := newGraceContext() var lastIndex uint32 diff --git a/cli/server/server_test.go b/cli/server/server_test.go index f3bb25fee..4be79c892 100644 --- a/cli/server/server_test.go +++ b/cli/server/server_test.go @@ -164,7 +164,6 @@ func TestRestoreDB(t *testing.T) { // and then restore set.String("in", testDump, "") - set.Int("skip", 0, "") set.String("dump", saveDump, "") require.NoError(t, restoreDB(ctx)) }