4
4
"context"
5
5
"crypto/ecdsa"
6
6
"fmt"
7
+ "slices"
8
+ "strconv"
7
9
"sync"
8
10
"time"
9
11
@@ -14,7 +16,11 @@ import (
14
16
"github.com/nspcc-dev/neofs-node/pkg/network/cache"
15
17
"github.com/nspcc-dev/neofs-node/pkg/services/audit/auditor"
16
18
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
19
+ storagegroupsvc "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/storagegroup"
20
+ "github.com/nspcc-dev/neofs-sdk-go/client"
17
21
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
22
+ cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
23
+ neofsecdsa "github.com/nspcc-dev/neofs-sdk-go/crypto/ecdsa"
18
24
"github.com/nspcc-dev/neofs-sdk-go/netmap"
19
25
"github.com/nspcc-dev/neofs-sdk-go/object"
20
26
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
@@ -226,23 +232,29 @@ func (c *ClientCache) getWrappedClient(info clientcore.NodeInfo) (neofsapiclient
226
232
return cInternal , nil
227
233
}
228
234
229
- func (c ClientCache ) ListSG (dst * storagegroup2. SearchSGDst , prm storagegroup2. SearchSGPrm ) error {
230
- cli , err := c .getWrappedClient ( prm . NodeInfo )
235
+ func (c ClientCache ) ListSG (ctx context. Context , node clientcore. NodeInfo , cnr cid. ID , notExpiredAt uint64 ) ([]oid. ID , error ) {
236
+ cli , err := c .Get ( node )
231
237
if err != nil {
232
- return fmt .Errorf ("could not get API client from cache" )
238
+ return nil , fmt .Errorf ("could not get API client from cache: %w" , err )
233
239
}
234
240
235
- var cliPrm neofsapiclient.SearchSGPrm
236
-
237
- cliPrm .SetContext (prm .Context )
238
- cliPrm .SetContainerID (prm .Container )
239
-
240
- res , err := cli .SearchSG (cliPrm )
241
- if err != nil {
242
- return err
241
+ fs := storagegroupsvc .SearchQuery ()
242
+ fs .AddFilter (object .AttributeExpirationEpoch , strconv .FormatUint (notExpiredAt , 10 ), object .MatchNumGE )
243
+ var opts client.SearchObjectsOptions
244
+ var cursor string
245
+ var next []client.SearchResultItem
246
+ var res []oid.ID
247
+ for {
248
+ next , cursor , err = cli .SearchObjects (ctx , cnr , fs , nil , cursor , (* neofsecdsa .Signer )(c .key ), opts )
249
+ if err != nil {
250
+ return nil , fmt .Errorf ("search objects RPC: %w" , err )
251
+ }
252
+ res = slices .Grow (res , len (res )+ len (next ))
253
+ for i := range next {
254
+ res = append (res , next [i ].ID )
255
+ }
256
+ if cursor == "" {
257
+ return res , nil
258
+ }
243
259
}
244
-
245
- dst .Objects = res .IDList ()
246
-
247
- return nil
248
260
}
0 commit comments