range-export: check serverside that head > tail

This commit is contained in:
Hector Sanjuan 2023-02-14 16:37:51 +01:00
parent ec01036871
commit be1614a042
2 changed files with 5 additions and 5 deletions
cli
node/impl/full

View File

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

View File

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