chain get: hamt-address type
This commit is contained in:
parent
2ff4a2846b
commit
13a8e2c09d
17
cli/chain.go
17
cli/chain.go
@ -12,6 +12,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
cborutil "github.com/filecoin-project/go-cbor-util"
|
cborutil "github.com/filecoin-project/go-cbor-util"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
@ -462,6 +463,8 @@ var chainGetCmd = &cli.Command{
|
|||||||
return handleAmt(ctx, api, obj.Cid)
|
return handleAmt(ctx, api, obj.Cid)
|
||||||
case "hamt-epoch":
|
case "hamt-epoch":
|
||||||
return handleHamtEpoch(ctx, api, obj.Cid)
|
return handleHamtEpoch(ctx, api, obj.Cid)
|
||||||
|
case "hamt-address":
|
||||||
|
return handleHamtAddress(ctx, api, obj.Cid)
|
||||||
case "cronevent":
|
case "cronevent":
|
||||||
cbu = new(power.CronEvent)
|
cbu = new(power.CronEvent)
|
||||||
default:
|
default:
|
||||||
@ -539,6 +542,20 @@ func handleHamtEpoch(ctx context.Context, api api.FullNode, r cid.Cid) error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleHamtAddress(ctx context.Context, api api.FullNode, r cid.Cid) error {
|
||||||
|
s := &apiIpldStore{ctx, api}
|
||||||
|
mp := adt.AsMap(s, r)
|
||||||
|
return mp.ForEach(nil, func(key string) error {
|
||||||
|
addr, err := address.NewFromBytes([]byte(key))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("%s\n", addr)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func printTipSet(format string, ts *types.TipSet) {
|
func printTipSet(format string, ts *types.TipSet) {
|
||||||
format = strings.ReplaceAll(format, "<height>", fmt.Sprint(ts.Height()))
|
format = strings.ReplaceAll(format, "<height>", fmt.Sprint(ts.Height()))
|
||||||
format = strings.ReplaceAll(format, "<time>", time.Unix(int64(ts.MinTimestamp()), 0).Format(time.Stamp))
|
format = strings.ReplaceAll(format, "<time>", time.Unix(int64(ts.MinTimestamp()), 0).Format(time.Stamp))
|
||||||
|
Loading…
Reference in New Issue
Block a user