From 6d4beea1873764056691c921c9908cfd79c2d764 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Tue, 18 Oct 2022 16:03:03 +0300 Subject: [PATCH] [#1902] tree: Extend grpc service with `ListTrees` method Signed-off-by: Pavel Karpy --- pkg/services/tree/service.go | 45 ++++++++++++++++++++++++++ pkg/services/tree/service.pb.go | Bin 108982 -> 118636 bytes pkg/services/tree/service.proto | 25 ++++++++++++++ pkg/services/tree/service_grpc.pb.go | Bin 16729 -> 18231 bytes pkg/services/tree/service_neofs.pb.go | Bin 51945 -> 57224 bytes 5 files changed, 70 insertions(+) diff --git a/pkg/services/tree/service.go b/pkg/services/tree/service.go index 03d6673b94..16ec780caf 100644 --- a/pkg/services/tree/service.go +++ b/pkg/services/tree/service.go @@ -522,6 +522,51 @@ func (s *Service) GetOpLog(req *GetOpLogRequest, srv TreeService_GetOpLogServer) } } +func (s *Service) TreeList(ctx context.Context, req *TreeListRequest) (*TreeListResponse, error) { + var cid cidSDK.ID + + err := cid.Decode(req.GetBody().GetContainerId()) + if err != nil { + return nil, err + } + + // just verify the signature, not ACL checks + // since tree ID list is not protected like + // the containers list + err = verifyMessage(req) + if err != nil { + return nil, err + } + + ns, pos, err := s.getContainerNodes(cid) + if err != nil { + return nil, err + } + if pos < 0 { + var resp *TreeListResponse + var outErr error + err = s.forEachNode(ctx, ns, func(c TreeServiceClient) bool { + resp, outErr = c.TreeList(ctx, req) + return outErr == nil + }) + if err != nil { + return nil, err + } + return resp, outErr + } + + ids, err := s.forest.TreeList(cid) + if err != nil { + return nil, err + } + + return &TreeListResponse{ + Body: &TreeListResponse_Body{ + Ids: ids, + }, + }, nil +} + func protoToMeta(arr []*KeyValue) []pilorama.KeyValue { meta := make([]pilorama.KeyValue, len(arr)) for i, kv := range arr { diff --git a/pkg/services/tree/service.pb.go b/pkg/services/tree/service.pb.go index 09236fcf89a708b6dc78279440ea5137d3b0e369..303fcd9499682d79e4b43bfcb6f020a51a5b560b 100644 GIT binary patch delta 6220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ha`zZZIT8_{( zK5}JH$IT;TBgKsRrRc-)2RZvLiiFBXQID98_OX+7%PO#cS7QE1(+(V?ZG;P_Lypra F`hWYnTZ;ey diff --git a/pkg/services/tree/service.proto b/pkg/services/tree/service.proto index 9bcefbf956..473ef84f96 100644 --- a/pkg/services/tree/service.proto +++ b/pkg/services/tree/service.proto @@ -39,6 +39,8 @@ service TreeService { rpc GetNodeByPath (GetNodeByPathRequest) returns (GetNodeByPathResponse); // GetSubTree returns tree corresponding to a specific node. rpc GetSubTree (GetSubTreeRequest) returns (stream GetSubTreeResponse); + // TreeList return list of the existing trees in the container. + rpc TreeList (TreeListRequest) returns (TreeListResponse); /* Synchronization API */ @@ -273,6 +275,29 @@ message GetSubTreeResponse { Signature signature = 2; }; +message TreeListRequest { + message Body { + // Container ID in V2 format. + bytes container_id = 1; + } + + // Request body. + Body body = 1; + // Request signature. + Signature signature = 2; +} + +message TreeListResponse { + message Body { + // Tree IDs. + repeated string ids = 1; + } + + // Response body. + Body body = 1; + Signature signature = 2; +} + message ApplyRequest { message Body { diff --git a/pkg/services/tree/service_grpc.pb.go b/pkg/services/tree/service_grpc.pb.go index 14e21305b8f2c84480444d67b444969d38ccdcfc..aca152ad0969f5898892aa030f8a95464f4bd9d3 100644 GIT binary patch delta 532 zcmccF#JIhWaf1@OTS!rAs!wKdi9%6oNoi4@LJo+XpQccfk*bhd0pw)nr7M&G6%{LF z=7B|%^Ycm)GxJi5^td=-x+fhdHYzLbeOb=6gd<8Sbb!H9sE2U*2rMK9LbwL}c;>=981Bcua!}Zr1Y@V?yu} zIHn+YlPvDSWhNi=%R_KJq#i?X1bHnc%SH)v80sig=y|3TZ@%C%1<6)HUeU?6yW}Rz zYt>Hfmlm7M=_AYxR5f{`$4s~xn=h)1BkbM$QFAJSH@RQu9$evMf2Vu|NAckC$s1;~ OPcE3kx>>I8v<(0PdSuA} delta 22 ecmeC!&-`*K^9G^5$^IMIC-bjl-Mn|vX&V4@0}37h