Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cmd: sort actor CIDs alphabetically before printing #6244

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions cmd/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"os"
"reflect"
"sort"
"strconv"

"github.com/filecoin-project/go-address"
Expand Down Expand Up @@ -651,16 +652,39 @@ var stateSysActorCIDsCmd = &cmds.Command{
}
buf.WriteString(fmt.Sprintf("Actor Version: %d\n", actorVersion))

manifestCid, err := env.(*node.Env).ChainAPI.StateActorManifestCID(ctx, nv)
if err != nil {
return err
}
buf.WriteString(fmt.Sprintf("Manifest CID: %v\n", manifestCid))

tw := tablewriter.New(tablewriter.Col("Actor"), tablewriter.Col("CID"))

actorsCids, err := env.(*node.Env).ChainAPI.StateActorCodeCIDs(ctx, nv)
if err != nil {
return err
}
for name, cid := range actorsCids {

type actorCid struct {
actorName string
actorCID string
}

var actorsCid []actorCid
for name, c := range actorsCids {
actorsCid = append(actorsCid, actorCid{
actorName: name,
actorCID: c.String(),
})
}
sort.Slice(actorsCid, func(i, j int) bool {
return actorsCid[i].actorName < actorsCid[j].actorName
})

for _, ac := range actorsCid {
tw.Write(map[string]interface{}{
"Actor": name,
"CID": cid.String(),
"Actor": ac.actorName,
"CID": ac.actorCID,
})
}

Expand Down
Loading