feat: cli(compute-state) default to the tipset at the given epoch
Previously, we'd use the current head if not otherwise specified, even when the user specified a epoch. Now: 1. If the user specifies nothing, we use head head's epoch. 2. If the user specifies a tipset and no epoch, we use that tipset and the epoch of that tipset. 3. If the user specifies an epoch and no tipset, use the tipset at that epoch (based on the current head). 4. Finally, if the user species both, use both (allowing the epoch/tipset to disagree).
This commit is contained in:
parent
9e4f1a4d23
commit
dfd3b10182
11
cli/state.go
11
cli/state.go
@ -1065,12 +1065,19 @@ var StateComputeStateCmd = &cli.Command{
|
||||
|
||||
ctx := ReqContext(cctx)
|
||||
|
||||
ts, err := LoadTipSet(ctx, cctx, api)
|
||||
h := abi.ChainEpoch(cctx.Uint64("vm-height"))
|
||||
var ts *types.TipSet
|
||||
if tss := cctx.String("tipset"); tss != "" {
|
||||
ts, err = ParseTipSetRef(ctx, api, tss)
|
||||
} else if h > 0 {
|
||||
ts, err = api.ChainGetTipSetByHeight(ctx, h, types.EmptyTSK)
|
||||
} else {
|
||||
ts, err = api.ChainHead(ctx)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
h := abi.ChainEpoch(cctx.Uint64("vm-height"))
|
||||
if h == 0 {
|
||||
h = ts.Height()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user