forked from TrueCloudLab/neoneo-go
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:
parent
df5ee4abdc
commit
de15d42861
3 changed files with 12 additions and 12 deletions
|
@ -40,17 +40,14 @@ func TestDBRestore(t *testing.T) {
|
||||||
// First 15 blocks.
|
// First 15 blocks.
|
||||||
e.Run(t, append(baseArgs, "--count", "15")...)
|
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.
|
// Big count.
|
||||||
e.RunWithError(t, append(baseArgs, "--count", "1000", "--skip", "15")...)
|
e.RunWithError(t, append(baseArgs, "--count", "1000")...)
|
||||||
|
|
||||||
// Continue 15..25
|
// Continue 15..25
|
||||||
e.Run(t, append(baseArgs, "--count", "10", "--skip", "15")...)
|
e.Run(t, append(baseArgs, "--count", "10")...)
|
||||||
|
|
||||||
// Continue till end.
|
// Continue till end.
|
||||||
e.Run(t, append(baseArgs, "--skip", "25")...)
|
e.Run(t, baseArgs...)
|
||||||
|
|
||||||
// Dump and compare.
|
// Dump and compare.
|
||||||
dumpPath := path.Join(tmpDir, "testdump.acc")
|
dumpPath := path.Join(tmpDir, "testdump.acc")
|
||||||
|
|
|
@ -52,10 +52,6 @@ func NewCommands() []cli.Command {
|
||||||
var cfgCountInFlags = make([]cli.Flag, len(cfgWithCountFlags))
|
var cfgCountInFlags = make([]cli.Flag, len(cfgWithCountFlags))
|
||||||
copy(cfgCountInFlags, cfgWithCountFlags)
|
copy(cfgCountInFlags, cfgWithCountFlags)
|
||||||
cfgCountInFlags = append(cfgCountInFlags,
|
cfgCountInFlags = append(cfgCountInFlags,
|
||||||
cli.UintFlag{
|
|
||||||
Name: "skip, s",
|
|
||||||
Usage: "number of blocks to skip (default: 0)",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "in, i",
|
Name: "in, i",
|
||||||
Usage: "Input file (stdin if not given)",
|
Usage: "Input file (stdin if not given)",
|
||||||
|
@ -219,7 +215,6 @@ func restoreDB(ctx *cli.Context) error {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
count := uint32(ctx.Uint("count"))
|
count := uint32(ctx.Uint("count"))
|
||||||
skip := uint32(ctx.Uint("skip"))
|
|
||||||
|
|
||||||
var inStream = os.Stdin
|
var inStream = os.Stdin
|
||||||
if in := ctx.String("in"); in != "" {
|
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",
|
return cli.NewExitError(fmt.Errorf("expected height: %d, dump starts at %d",
|
||||||
chain.BlockHeight()+1, start), 1)
|
chain.BlockHeight()+1, start), 1)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var skip uint32
|
||||||
|
if chain.BlockHeight() != 0 {
|
||||||
skip = chain.BlockHeight() + 1 - start
|
skip = chain.BlockHeight() + 1 - start
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,6 +263,11 @@ func restoreDB(ctx *cli.Context) error {
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
count = allBlocks - skip
|
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()
|
gctx := newGraceContext()
|
||||||
var lastIndex uint32
|
var lastIndex uint32
|
||||||
|
|
|
@ -164,7 +164,6 @@ func TestRestoreDB(t *testing.T) {
|
||||||
|
|
||||||
// and then restore
|
// and then restore
|
||||||
set.String("in", testDump, "")
|
set.String("in", testDump, "")
|
||||||
set.Int("skip", 0, "")
|
|
||||||
set.String("dump", saveDump, "")
|
set.String("dump", saveDump, "")
|
||||||
require.NoError(t, restoreDB(ctx))
|
require.NoError(t, restoreDB(ctx))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue