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:
parent
4d770e3c37
commit
4736dad8f0
1 changed files with 2 additions and 2 deletions
|
@ -168,7 +168,7 @@ func dumpDB(ctx *cli.Context) error {
|
||||||
count = chainHeight - skip
|
count = chainHeight - skip
|
||||||
}
|
}
|
||||||
writer.WriteLE(count)
|
writer.WriteLE(count)
|
||||||
for i := skip + 1; i <= count; i++ {
|
for i := skip + 1; i <= skip+count; i++ {
|
||||||
bh := chain.GetHeaderHash(int(i))
|
bh := chain.GetHeaderHash(int(i))
|
||||||
b, err := chain.GetBlock(bh)
|
b, err := chain.GetBlock(bh)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -227,7 +227,7 @@ func restoreDB(ctx *cli.Context) error {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(err, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for ; i < count; i++ {
|
for ; i < skip+count; i++ {
|
||||||
b := &core.Block{}
|
b := &core.Block{}
|
||||||
b.DecodeBinary(reader)
|
b.DecodeBinary(reader)
|
||||||
if reader.Err != nil {
|
if reader.Err != nil {
|
||||||
|
|
Loading…
Reference in a new issue