forked from TrueCloudLab/frostfs-node
[#175] adm: list containers using `containersOf`
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>support/v0.36
parent
8e5a0dcf27
commit
e85e5382e4
|
@ -42,15 +42,27 @@ func getContainerContractHash(cmd *cobra.Command, inv *invoker.Invoker, c Client
|
|||
}
|
||||
|
||||
func getContainersList(inv *invoker.Invoker, ch util.Uint160) ([][]byte, error) {
|
||||
res, err := inv.Call(ch, "list", "")
|
||||
sid, r, err := unwrap.SessionIterator(inv.Call(ch, "containersOf", ""))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%w: %v", errInvalidContainerResponse, err)
|
||||
}
|
||||
itm, err := unwrap.Item(res, err)
|
||||
if _, ok := itm.(stackitem.Null); !ok {
|
||||
return unwrap.ArrayOfBytes(res, err)
|
||||
// Nothing bad, except live session on the server, do not report to the user.
|
||||
defer func() { _ = inv.TerminateSession(sid) }()
|
||||
|
||||
var lst [][]byte
|
||||
|
||||
items, err := inv.TraverseIterator(sid, &r, 0)
|
||||
for err == nil && len(items) != 0 {
|
||||
for j := range items {
|
||||
b, err := items[j].TryBytes()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%w: %v", errInvalidContainerResponse, err)
|
||||
}
|
||||
lst = append(lst, b)
|
||||
}
|
||||
items, err = inv.TraverseIterator(sid, &r, 0)
|
||||
}
|
||||
return nil, nil
|
||||
return lst, err
|
||||
}
|
||||
|
||||
func dumpContainers(cmd *cobra.Command, _ []string) error {
|
||||
|
|
Loading…
Reference in New Issue