chain get: @Hu: for uvaring hamt keys
This commit is contained in:
parent
4d92798f5b
commit
9a7aa3fc87
@ -433,6 +433,8 @@ var chainGetCmd = &cli.Command{
|
||||
Note:
|
||||
You can use special path elements to traverse through some data structures:
|
||||
- /ipfs/[cid]/@H:elem - get 'elem' from hamt
|
||||
- /ipfs/[cid]/@Hi:123 - get varint elem 123 from hamt
|
||||
- /ipfs/[cid]/@Hu:123 - get uvarint elem 123 from hamt
|
||||
- /ipfs/[cid]/@Ha:t01 - get element under Addr(t01).Bytes
|
||||
- /ipfs/[cid]/@A:10 - get 10th amt element
|
||||
`,
|
||||
|
@ -285,6 +285,17 @@ func resolveOnce(bs blockstore.Blockstore) func(ctx context.Context, ds ipld.Nod
|
||||
names[0] = "@H:" + ik.Key()
|
||||
}
|
||||
|
||||
if strings.HasPrefix(names[0], "@Hu:") {
|
||||
i, err := strconv.ParseUint(names[0][4:], 10, 64)
|
||||
if err != nil {
|
||||
return nil, nil, xerrors.Errorf("parsing int64: %w", err)
|
||||
}
|
||||
|
||||
ik := adt.UIntKey(i)
|
||||
|
||||
names[0] = "@H:" + ik.Key()
|
||||
}
|
||||
|
||||
if strings.HasPrefix(names[0], "@H:") {
|
||||
cst := cbor.NewCborStore(bs)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user