cli: fix skip usage in DB dump/restore

It was failing to process any blocks at all when (skip >= count) and in other
cases it processed wrong number of blocks.
This commit is contained in:
Roman Khimov 2019-11-08 16:56:54 +03:00
parent 4d770e3c37
commit 4736dad8f0

View file

@ -168,7 +168,7 @@ func dumpDB(ctx *cli.Context) error {
count = chainHeight - skip
}
writer.WriteLE(count)
for i := skip + 1; i <= count; i++ {
for i := skip + 1; i <= skip+count; i++ {
bh := chain.GetHeaderHash(int(i))
b, err := chain.GetBlock(bh)
if err != nil {
@ -227,7 +227,7 @@ func restoreDB(ctx *cli.Context) error {
return cli.NewExitError(err, 1)
}
}
for ; i < count; i++ {
for ; i < skip+count; i++ {
b := &core.Block{}
b.DecodeBinary(reader)
if reader.Err != nil {