range-export: check serverside that head > tail
This commit is contained in:
parent
ec01036871
commit
be1614a042
@ -1202,11 +1202,7 @@ var ChainExportRangeCmd = &cli.Command{
|
||||
defer closer()
|
||||
ctx := ReqContext(cctx)
|
||||
|
||||
if !cctx.Args().Present() {
|
||||
return fmt.Errorf("must specify filename to export chain to")
|
||||
}
|
||||
|
||||
head, tail := &types.TipSet{}, &types.TipSet{}
|
||||
var head, tail *types.TipSet
|
||||
headstr := cctx.String("head")
|
||||
if headstr == "@head" {
|
||||
head, err = api.ChainHead(ctx)
|
||||
|
@ -602,6 +602,10 @@ func (a ChainAPI) ChainExportRangeInternal(ctx context.Context, head, tail types
|
||||
if err != nil {
|
||||
return xerrors.Errorf("loading tipset %s: %w", tail, err)
|
||||
}
|
||||
if headTs.Height() < tailTs.Height() {
|
||||
return xerrors.Errorf("Height of head-tipset (%d) must be greater or equal to the height of the tail-tipset (%d)", headTs.Height(), tailTs.Height())
|
||||
}
|
||||
|
||||
fileName := fmt.Sprintf("./snapshot_%d_%d_%d.car", tailTs.Height(), headTs.Height(), time.Now().Unix())
|
||||
absFileName, err := filepath.Abs(fileName)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user