@@ -40,8 +40,10 @@ import (
40
40
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
41
41
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
42
42
protoobject "github.com/nspcc-dev/neofs-sdk-go/proto/object"
43
+ protosession "github.com/nspcc-dev/neofs-sdk-go/proto/session"
43
44
apireputation "github.com/nspcc-dev/neofs-sdk-go/reputation"
44
45
"github.com/nspcc-dev/neofs-sdk-go/user"
46
+ "github.com/nspcc-dev/neofs-sdk-go/version"
45
47
"go.uber.org/zap"
46
48
)
47
49
@@ -244,6 +246,7 @@ func initObjectService(c *cfg) {
244
246
mNumber , err := c .shared .basics .cli .MagicNumber ()
245
247
fatalOnErr (err )
246
248
249
+ os := & objectSource {get : sGet }
247
250
sPut := putsvc .NewService (& transport {clients : putConstructor }, c ,
248
251
putsvc .WithNetworkMagic (mNumber ),
249
252
putsvc .WithKeyStorage (keyStorage ),
@@ -257,7 +260,7 @@ func initObjectService(c *cfg) {
257
260
putsvc .WithWorkerPools (c .cfgObject .pool .putRemote , c .cfgObject .pool .putLocal ),
258
261
putsvc .WithLogger (c .log ),
259
262
putsvc .WithSplitChainVerifier (split .NewVerifier (sGet )),
260
- putsvc .WithTombstoneVerifier (tombstone .NewVerifier (objectSource { sGet , sSearch } )),
263
+ putsvc .WithTombstoneVerifier (tombstone .NewVerifier (os )),
261
264
)
262
265
263
266
sDelete := deletesvc .New (
@@ -314,6 +317,7 @@ func initObjectService(c *cfg) {
314
317
keys : keyStorage ,
315
318
}
316
319
server := objectService .New (objSvc , mNumber , fsChain , storage , c .metaService , c .shared .basics .key .PrivateKey , c .metricsCollector , aclChecker , aclSvc , coreConstructor )
320
+ os .server = server
317
321
318
322
for _ , srv := range c .cfgGRPC .servers {
319
323
protoobject .RegisterObjectServiceServer (srv , server )
@@ -639,16 +643,9 @@ func (x storageForObjectService) GetSessionPrivateKey(usr user.ID, uid uuid.UUID
639
643
640
644
type objectSource struct {
641
645
get * getsvc.Service
642
- search * searchsvc.Service
643
- }
644
-
645
- type searchWriter struct {
646
- ids []oid.ID
647
- }
648
-
649
- func (w * searchWriter ) WriteIDs (ids []oid.ID ) error {
650
- w .ids = append (w .ids , ids ... )
651
- return nil
646
+ server interface {
647
+ ProcessSearch (ctx context.Context , req * protoobject.SearchV2Request ) ([]client.SearchResultItem , []byte , error )
648
+ }
652
649
}
653
650
654
651
func (o objectSource ) Head (ctx context.Context , addr oid.Address ) (* objectSDK.Object , error ) {
@@ -664,20 +661,30 @@ func (o objectSource) Head(ctx context.Context, addr oid.Address) (*objectSDK.Ob
664
661
return hw .h , err
665
662
}
666
663
667
- func (o objectSource ) Search (ctx context.Context , cnr cid.ID , filters objectSDK.SearchFilters ) ([]oid.ID , error ) {
668
- var sw searchWriter
669
-
670
- var sPrm searchsvc.Prm
671
- sPrm .SetWriter (& sw )
672
- sPrm .WithSearchFilters (filters )
673
- sPrm .WithContainerID (cnr )
674
-
675
- err := o .search .Search (ctx , sPrm )
664
+ func (o objectSource ) SearchOne (ctx context.Context , cnr cid.ID , filters objectSDK.SearchFilters ) (oid.ID , error ) {
665
+ var id oid.ID
666
+ res , _ , err := o .server .ProcessSearch (ctx , & protoobject.SearchV2Request {
667
+ Body : & protoobject.SearchV2Request_Body {
668
+ ContainerId : cnr .ProtoMessage (),
669
+ Version : 1 ,
670
+ Filters : filters .ProtoMessage (),
671
+ Cursor : "" ,
672
+ Count : 1 ,
673
+ Attributes : nil ,
674
+ },
675
+ MetaHeader : & protosession.RequestMetaHeader {
676
+ Version : version .Current ().ProtoMessage (),
677
+ Ttl : 2 ,
678
+ },
679
+ })
676
680
if err != nil {
677
- return nil , err
681
+ return id , err
678
682
}
679
683
680
- return sw .ids , nil
684
+ if len (res ) == 1 {
685
+ return res [0 ].ID , nil
686
+ }
687
+ return id , nil
681
688
}
682
689
683
690
// IsLocalNodePublicKey checks whether given binary-encoded public key is
0 commit comments