morph: Fix batch size in TraverseIterator() #1000
2 changed files with 9 additions and 4 deletions
|
@ -177,12 +177,12 @@ func dumpCustomZoneHashes(cmd *cobra.Command, nnsHash util.Uint160, zone string,
|
|||
_ = inv.TerminateSession(sessionID)
|
||||
}()
|
||||
|
||||
items, err := inv.TraverseIterator(sessionID, &iter, nnsMaxTokens)
|
||||
items, err := inv.TraverseIterator(sessionID, &iter, 0)
|
||||
for err == nil && len(items) != 0 {
|
||||
for i := range items {
|
||||
processItem(items[i])
|
||||
}
|
||||
items, err = inv.TraverseIterator(sessionID, &iter, nnsMaxTokens)
|
||||
items, err = inv.TraverseIterator(sessionID, &iter, 0)
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("error during NNS domains iteration: %w", err)
|
||||
|
|
|
@ -260,8 +260,13 @@ func (c *Client) TestInvokeIterator(cb func(stackitem.Item) error, batchSize int
|
|||
_ = c.rpcActor.TerminateSession(sid)
|
||||
}()
|
||||
|
||||
// Batch size for TraverseIterator() can restricted on the server-side.
|
||||
traverseBatchSize := batchSize
|
||||
if invoker.DefaultIteratorResultItems < traverseBatchSize {
|
||||
traverseBatchSize = invoker.DefaultIteratorResultItems
|
||||
}
|
||||
for {
|
||||
items, err := c.rpcActor.TraverseIterator(sid, &r, batchSize)
|
||||
items, err := c.rpcActor.TraverseIterator(sid, &r, traverseBatchSize)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -271,7 +276,7 @@ func (c *Client) TestInvokeIterator(cb func(stackitem.Item) error, batchSize int
|
|||
return err
|
||||
}
|
||||
}
|
||||
if len(items) < batchSize {
|
||||
if len(items) < traverseBatchSize {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue