cli: remove --skip parameter from restore

It isn't really a parameter and it's value can be deduced automatically.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgeniy Stratonikov 2021-07-16 10:45:34 +03:00
parent df5ee4abdc
commit de15d42861
3 changed files with 12 additions and 12 deletions

View file

@ -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")

View file

@ -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

View file

@ -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))
}