From d631ee55c9a6f39b9a6d4ba0612f1e427ab02a56 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Wed, 3 Apr 2024 11:28:26 +0300 Subject: [PATCH] [#351] policy: Use iterators to list chains Signed-off-by: Denis Kirillov --- internal/frostfs/policy/contract/contract.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/frostfs/policy/contract/contract.go b/internal/frostfs/policy/contract/contract.go index 0da24a70..eac4ea64 100644 --- a/internal/frostfs/policy/contract/contract.go +++ b/internal/frostfs/policy/contract/contract.go @@ -41,6 +41,11 @@ type Config struct { Key *keys.PrivateKey } +const ( + batchSize = 100 + iteratorChainsByPrefix = "iteratorChainsByPrefix" +) + var _ policy.Contract = (*Client)(nil) // New creates new Policy contract wrapper. @@ -114,7 +119,8 @@ func (c *Client) RemoveChain(kind policycontract.Kind, entity string, name []byt } func (c *Client) ListChains(kind policycontract.Kind, entity string, name []byte) ([][]byte, error) { - items, err := c.policyContract.ListChainsByPrefix(big.NewInt(int64(kind)), entity, name) + items, err := commonclient.ReadIteratorItems(c.actor, batchSize, c.contractHash, iteratorChainsByPrefix, + big.NewInt(int64(kind)), entity, name) if err != nil { return nil, err }