Use containersOf in neofs-adm #200

Merged
fyrchik merged 2 commits from fyrchik/frostfs-node:fix-containers-of into master 2023-04-04 07:26:24 +00:00
Showing only changes of commit 6a7155fc90 - Show all commits

View file

@ -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) }()
carpawell marked this conversation as resolved
Review

not sure exactly, but not that necessary as i remember according to my new neo-go API discoverings (4 months ago, could be wrong), actors do not do that as i remember (again, could be wrong)

not sure exactly, but not that necessary as i remember according to my new neo-go API discoverings (4 months ago, could be wrong), actors do not do that as i remember (again, could be wrong)
Review

That is why we ignore error.

That is why we ignore error.
Review

I meant that it looks like neo-go team also thinks that we can drop defer at all. But not a problem.

I meant that it looks like `neo-go` team also thinks that we can drop `defer` at all. But not a problem.
Review

It costs us (almost) nothing and neo-go internals can change any time.

It costs us (almost) nothing and neo-go internals can change any time.
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 {