Skip to content

Commit

Permalink
feat: add toolshed commands to inspect statetree size
Browse files Browse the repository at this point in the history
  • Loading branch information
travisperson committed Jan 19, 2023
1 parent 0934cf0 commit a0c58b5
Show file tree
Hide file tree
Showing 3 changed files with 543 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cli/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,16 @@ func ParseTipSetString(ts string) ([]cid.Cid, error) {
return cids, nil
}

type TipSetResolver interface {
ChainHead(context.Context) (*types.TipSet, error)
ChainGetTipSetByHeight(context.Context, abi.ChainEpoch, types.TipSetKey) (*types.TipSet, error)
ChainGetTipSet(context.Context, types.TipSetKey) (*types.TipSet, error)
}

// LoadTipSet gets the tipset from the context, or the head from the API.
//
// It always gets the head from the API so commands use a consistent tipset even if time pases.
func LoadTipSet(ctx context.Context, cctx *cli.Context, api v0api.FullNode) (*types.TipSet, error) {
func LoadTipSet(ctx context.Context, cctx *cli.Context, api TipSetResolver) (*types.TipSet, error) {
tss := cctx.String("tipset")
if tss == "" {
return api.ChainHead(ctx)
Expand All @@ -264,7 +270,7 @@ func LoadTipSet(ctx context.Context, cctx *cli.Context, api v0api.FullNode) (*ty
return ParseTipSetRef(ctx, api, tss)
}

func ParseTipSetRef(ctx context.Context, api v0api.FullNode, tss string) (*types.TipSet, error) {
func ParseTipSetRef(ctx context.Context, api TipSetResolver, tss string) (*types.TipSet, error) {
if tss[0] == '@' {
if tss == "@head" {
return api.ChainHead(ctx)
Expand Down
2 changes: 2 additions & 0 deletions cmd/lotus-shed/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ func main() {

local := []*cli.Command{
addressCmd,
statActorCmd,
statObjCmd,
base64Cmd,
base32Cmd,
base16Cmd,
Expand Down
Loading

0 comments on commit a0c58b5

Please sign in to comment.