From 3b2ea6b8f4e954bc621735537f53f12b839d6e06 Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Fri, 22 Nov 2019 16:32:21 +0300 Subject: [PATCH 1/3] 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, From 982a953d8af943d0559dde57755d18524c6b55ce Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Fri, 22 Nov 2019 17:23:03 +0300 Subject: [PATCH 2/3] update go.sum --- go.sum | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/go.sum b/go.sum index fce9983..f06a499 100644 --- a/go.sum +++ b/go.sum @@ -71,8 +71,7 @@ github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjW github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 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 h1:jLc5O+Wdpaq7L4lNYFX7li+OP4I1FsvvcPW1NXm3erY= 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= From c2d1ee7495ab7724c8571d048756cfe00b88ec94 Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Fri, 22 Nov 2019 17:23:36 +0300 Subject: [PATCH 3/3] CHANGELOG for v0.2.1 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4b71c8..c2ce5b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog This is the changelog for NeoFS Proto +## [0.2.1] - 2019-11-22 + +### Changed +- Removed SendPutRequest +- MakePutRequestHeader sets only object and token + ## [0.2.0] - 2019-11-21 ### Added @@ -20,3 +26,4 @@ This is the changelog for NeoFS Proto Initial public release [0.2.0]: https://github.com/nspcc-dev/neofs-proto/compare/v0.1.0...v0.2.0 +[0.2.1]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.0...v0.2.1