container: Reduce iterations through container list #1577

Merged
fyrchik merged 3 commits from elebedeva/frostfs-node:feat/container-batching into master 2024-12-28 10:05:35 +00:00
2 changed files with 2 additions and 2 deletions
Showing only changes of commit c0221d76e6 - Show all commits

View file

@ -6,7 +6,7 @@ const (
subsection = "container" subsection = "container"
listStreamSubsection = "list_stream" listStreamSubsection = "list_stream"
// ContainerBatchSizeDefault represents he maximum amount of containers to send via stream at once. // ContainerBatchSizeDefault represents the maximum amount of containers to send via stream at once.
ContainerBatchSizeDefault = 1000 ContainerBatchSizeDefault = 1000
) )

View file

@ -36,7 +36,6 @@ func (c *Client) IterateContainersOf(idUser *user.ID, cb func(item cid.ID) error
rawID = idUser.WalletBytes() rawID = idUser.WalletBytes()
} }
cnrHash := c.client.ContractAddress()
itemCb := func(item stackitem.Item) error { itemCb := func(item stackitem.Item) error {
Review

This line was right before the TestInvokeIterator previously, why has it moved?

This line was right before the `TestInvokeIterator` previously, why has it moved?
Review

Accidentally. Moved it back.

Accidentally. Moved it back.
id, err := getCIDfromStackItem(item) id, err := getCIDfromStackItem(item)
if err != nil { if err != nil {
@ -57,6 +56,7 @@ func (c *Client) IterateContainersOf(idUser *user.ID, cb func(item cid.ID) error
// 512 is big enough value and it is beautiful. // 512 is big enough value and it is beautiful.
const batchSize = 512 const batchSize = 512
cnrHash := c.client.ContractAddress()
err := c.client.Morph().TestInvokeIterator(itemCb, batchSize, cnrHash, containersOfMethod, rawID) err := c.client.Morph().TestInvokeIterator(itemCb, batchSize, cnrHash, containersOfMethod, rawID)
if err != nil && errors.Is(err, unwrap.ErrNoSessionID) { if err != nil && errors.Is(err, unwrap.ErrNoSessionID) {
return c.iterate(idUser, cb) return c.iterate(idUser, cb)