From ae9207427286fe33601e1d17fc878a8d14e22987 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 11 May 2022 19:35:01 +0300 Subject: [PATCH] [#1369] checksum: Upgrade SDK package Signed-off-by: Leonard Lyubich --- cmd/neofs-cli/modules/object.go | 30 ++++++++++++++---- cmd/neofs-cli/modules/storagegroup.go | 2 +- go.mod | 2 +- go.sum | Bin 98064 -> 98319 bytes .../engine/engine_test.go | 6 ++-- pkg/local_object_storage/metabase/db_test.go | 6 ++-- pkg/local_object_storage/metabase/put.go | 4 ++- pkg/local_object_storage/metabase/select.go | 3 +- .../metabase/select_test.go | 12 ++++--- pkg/local_object_storage/shard/shard_test.go | 6 ++-- pkg/services/audit/auditor/context.go | 4 ++- pkg/services/audit/auditor/por.go | 12 +++---- pkg/services/object/acl/eacl/v2/object.go | 26 +++++++++------ pkg/services/object/put/validation.go | 8 +++-- .../object_manager/storagegroup/collect.go | 5 +-- .../object_manager/transformer/transformer.go | 24 +++++++------- 16 files changed, 94 insertions(+), 56 deletions(-) diff --git a/cmd/neofs-cli/modules/object.go b/cmd/neofs-cli/modules/object.go index cccf76e3c..c16d115af 100644 --- a/cmd/neofs-cli/modules/object.go +++ b/cmd/neofs-cli/modules/object.go @@ -681,15 +681,20 @@ func getObjectHash(cmd *cobra.Command, _ []string) { res, err := internalclient.HeadObject(headPrm) exitOnErr(cmd, errf("rpc error: %w", err)) - var cs *checksum.Checksum + var cs checksum.Checksum + var csSet bool if tz { - cs = res.Header().PayloadHomomorphicHash() + cs, csSet = res.Header().PayloadHomomorphicHash() } else { - cs = res.Header().PayloadChecksum() + cs, csSet = res.Header().PayloadChecksum() } - cmd.Println(hex.EncodeToString(cs.Sum())) + if csSet { + cmd.Println(hex.EncodeToString(cs.Value())) + } else { + cmd.Println("Missing checksum in object header.") + } return } @@ -959,14 +964,27 @@ func saveAndPrintHeader(cmd *cobra.Command, obj *object.Object, filename string) return printHeader(cmd, obj) } +func printChecksum(cmd *cobra.Command, name string, recv func() (checksum.Checksum, bool)) { + var strVal string + + cs, csSet := recv() + if csSet { + strVal = hex.EncodeToString(cs.Value()) + } else { + strVal = "" + } + + cmd.Printf("%s: %s\n", name, strVal) +} + func printHeader(cmd *cobra.Command, obj *object.Object) error { cmd.Printf("ID: %s\n", obj.ID()) cmd.Printf("CID: %s\n", obj.ContainerID()) cmd.Printf("Owner: %s\n", obj.OwnerID()) cmd.Printf("CreatedAt: %d\n", obj.CreationEpoch()) cmd.Printf("Size: %d\n", obj.PayloadSize()) - cmd.Printf("HomoHash: %s\n", hex.EncodeToString(obj.PayloadHomomorphicHash().Sum())) - cmd.Printf("Checksum: %s\n", hex.EncodeToString(obj.PayloadChecksum().Sum())) + printChecksum(cmd, "HomoHash", obj.PayloadHomomorphicHash) + printChecksum(cmd, "Checksum", obj.PayloadChecksum) cmd.Printf("Type: %s\n", obj.Type()) cmd.Println("Attributes:") diff --git a/cmd/neofs-cli/modules/storagegroup.go b/cmd/neofs-cli/modules/storagegroup.go index ec7739575..cf8b263ef 100644 --- a/cmd/neofs-cli/modules/storagegroup.go +++ b/cmd/neofs-cli/modules/storagegroup.go @@ -255,7 +255,7 @@ func getSG(cmd *cobra.Command, _ []string) { cmd.Printf("Expiration epoch: %d\n", sg.ExpirationEpoch()) cmd.Printf("Group size: %d\n", sg.ValidationDataSize()) - cmd.Printf("Group hash: %s\n", sg.ValidationDataHash()) + printChecksum(cmd, "Group hash", sg.ValidationDataHash) if members := sg.Members(); len(members) > 0 { cmd.Println("Members:") diff --git a/go.mod b/go.mod index a27e6b32e..9edabaab2 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af // indirect github.com/nspcc-dev/neofs-api-go/v2 v2.12.1 github.com/nspcc-dev/neofs-contract v0.14.2 - github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.3.0.20220413072812-c961aea14446 + github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.3.0.20220413075357-96892d7bc4a8 github.com/nspcc-dev/tzhash v1.5.2 github.com/panjf2000/ants/v2 v2.4.0 github.com/paulmach/orb v0.2.2 diff --git a/go.sum b/go.sum index 9f2816c52b9e3baec65b30867f6df5d2803ef08c..909203424cd24c721634ca1d00a7346a079b4cf7 100644 GIT binary patch delta 175 zcmbR6kF~#nZG+pK$^NtWCWp=zcQ7?JHP^K?v#>NuF;7Z1NwiSNFtpOo3o|t@wsZ~j zxA2Pa_we&E3H2