From 3b2ea6b8f4e954bc621735537f53f12b839d6e06 Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Fri, 22 Nov 2019 16:32:21 +0300 Subject: [PATCH] Remove SendPutRequest and update MakePutRequestHeader - SendPutRequest unused and work not like expected - MakePutRequestHeader should not set epoch / ttl - remove unused internal functions and consts - update to latest neofs-crypto --- go.mod | 2 +- go.sum | 1 + object/utils.go | 43 ++----------------------------------------- 3 files changed, 4 insertions(+), 42 deletions(-) diff --git a/go.mod b/go.mod index 4649004..06fb5c0 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/golang/protobuf v1.3.2 github.com/google/uuid v1.1.1 github.com/mr-tron/base58 v1.1.2 - github.com/nspcc-dev/neofs-crypto v0.2.1 + github.com/nspcc-dev/neofs-crypto v0.2.2 github.com/nspcc-dev/netmap v1.6.1 github.com/nspcc-dev/tzhash v1.3.0 github.com/onsi/ginkgo v1.10.2 // indirect diff --git a/go.sum b/go.sum index 6b48f3f..fce9983 100644 --- a/go.sum +++ b/go.sum @@ -73,6 +73,7 @@ github.com/nspcc-dev/hrw v1.0.8 h1:vwRuJXZXgkMvf473vFzeWGCfY1WBVeSHAEHvR4u3/Cg= github.com/nspcc-dev/hrw v1.0.8/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU= github.com/nspcc-dev/neofs-crypto v0.2.1 h1:NxKexcW88vlHO/u7EYjx5Q1UaOQ7XhYrCsLSVgOcCxw= github.com/nspcc-dev/neofs-crypto v0.2.1/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA= +github.com/nspcc-dev/neofs-crypto v0.2.2/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA= github.com/nspcc-dev/netmap v1.6.1 h1:Pigqpqi6QSdRiusbq5XlO20A18k6Eyu7j9MzOfAE3CM= github.com/nspcc-dev/netmap v1.6.1/go.mod h1:mhV3UOg9ljQmu0teQShD6+JYX09XY5gu2I4hIByCH9M= github.com/nspcc-dev/rfc6979 v0.1.0 h1:Lwg7esRRoyK1Up/IN1vAef1EmvrBeMHeeEkek2fAJ6c= diff --git a/object/utils.go b/object/utils.go index f74fa2f..c0fb624 100644 --- a/object/utils.go +++ b/object/utils.go @@ -4,53 +4,14 @@ import ( "io" "code.cloudfoundry.org/bytefmt" - "github.com/nspcc-dev/neofs-proto/service" "github.com/nspcc-dev/neofs-proto/session" "github.com/pkg/errors" ) -const maxGetPayloadSize = 3584 * 1024 // 3.5 MiB - -func splitBytes(data []byte, maxSize int) (result [][]byte) { - l := len(data) - if l == 0 { - return [][]byte{data} - } - for i := 0; i < l; i += maxSize { - last := i + maxSize - if last > l { - last = l - } - result = append(result, data[i:last]) - } - return -} - -// SendPutRequest prepares object and sends it in chunks through protobuf stream. -func SendPutRequest(s Service_PutClient, obj *Object, epoch uint64, ttl uint32) (*PutResponse, error) { - // TODO split must take into account size of the marshalled Object - chunks := splitBytes(obj.Payload, maxGetPayloadSize) - obj.Payload = chunks[0] - if err := s.Send(MakePutRequestHeader(obj, epoch, ttl, nil)); err != nil { - return nil, err - } - for i := range chunks[1:] { - if err := s.Send(MakePutRequestChunk(chunks[i+1])); err != nil { - return nil, err - } - } - resp, err := s.CloseAndRecv() - if err != nil && err != io.EOF { - return nil, err - } - return resp, nil -} - -// MakePutRequestHeader combines object, epoch, ttl and session token value +// MakePutRequestHeader combines object and session token value // into header of object put request. -func MakePutRequestHeader(obj *Object, epoch uint64, ttl uint32, token *session.Token) *PutRequest { +func MakePutRequestHeader(obj *Object, token *session.Token) *PutRequest { return &PutRequest{ - RequestMetaHeader: service.RequestMetaHeader{TTL: ttl, Epoch: epoch}, R: &PutRequest_Header{Header: &PutRequest_PutHeader{ Object: obj, Token: token,