diff --git a/cmd/neofs-cli/modules/storagegroup/put.go b/cmd/neofs-cli/modules/storagegroup/put.go index 4dce711f5..53ff399ba 100644 --- a/cmd/neofs-cli/modules/storagegroup/put.go +++ b/cmd/neofs-cli/modules/storagegroup/put.go @@ -13,6 +13,7 @@ import ( objectCli "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/modules/object" sessionCli "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/modules/session" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/storagegroup" + "github.com/nspcc-dev/neofs-sdk-go/container" cid "github.com/nspcc-dev/neofs-sdk-go/container/id" "github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" @@ -69,10 +70,18 @@ func putSG(cmd *cobra.Command, _ []string) { } var ( - headPrm internalclient.HeadObjectPrm - putPrm internalclient.PutObjectPrm + headPrm internalclient.HeadObjectPrm + putPrm internalclient.PutObjectPrm + getCnrPrm internalclient.GetContainerPrm ) + cli := internalclient.GetSDKClientByFlag(cmd, pk, commonflags.RPC) + getCnrPrm.SetClient(cli) + getCnrPrm.SetContainer(cnr) + + resGetCnr, err := internalclient.GetContainer(getCnrPrm) + common.ExitOnErr(cmd, "get container RPC call: %w", err) + sessionCli.Prepare(cmd, cnr, nil, pk, &putPrm) objectCli.Prepare(cmd, &headPrm, &putPrm) @@ -83,11 +92,9 @@ func putSG(cmd *cobra.Command, _ []string) { key: pk, ownerID: &ownerID, prm: headPrm, - }, cnr, members) + }, cnr, members, !container.IsHomomorphicHashingDisabled(resGetCnr.Container())) common.ExitOnErr(cmd, "could not collect storage group members: %w", err) - cli := internalclient.GetSDKClientByFlag(cmd, pk, commonflags.RPC) - var netInfoPrm internalclient.NetworkInfoPrm netInfoPrm.SetClient(cli) diff --git a/pkg/services/object_manager/storagegroup/collect.go b/pkg/services/object_manager/storagegroup/collect.go index 8b26b2703..4fec35cbb 100644 --- a/pkg/services/object_manager/storagegroup/collect.go +++ b/pkg/services/object_manager/storagegroup/collect.go @@ -14,7 +14,7 @@ import ( // with information about members collected via HeadReceiver. // // Resulting storage group consists of physically stored objects only. -func CollectMembers(r objutil.HeadReceiver, cnr cid.ID, members []oid.ID) (*storagegroup.StorageGroup, error) { +func CollectMembers(r objutil.HeadReceiver, cnr cid.ID, members []oid.ID, calcHomoHash bool) (*storagegroup.StorageGroup, error) { var ( sumPhySize uint64 phyMembers []oid.ID @@ -37,25 +37,31 @@ func CollectMembers(r objutil.HeadReceiver, cnr cid.ID, members []oid.ID) (*stor phyMembers = append(phyMembers, id) sumPhySize += leaf.PayloadSize() cs, _ := leaf.PayloadHomomorphicHash() - phyHashes = append(phyHashes, cs.Value()) + + if calcHomoHash { + phyHashes = append(phyHashes, cs.Value()) + } }); err != nil { return nil, err } } - sumHash, err := tz.Concat(phyHashes) - if err != nil { - return nil, err - } - - var cs checksum.Checksum - tzHash := [64]byte{} - copy(tzHash[:], sumHash) - cs.SetTillichZemor(tzHash) - sg.SetMembers(phyMembers) sg.SetValidationDataSize(sumPhySize) - sg.SetValidationDataHash(cs) + + if calcHomoHash { + sumHash, err := tz.Concat(phyHashes) + if err != nil { + return nil, err + } + + var cs checksum.Checksum + tzHash := [64]byte{} + copy(tzHash[:], sumHash) + cs.SetTillichZemor(tzHash) + + sg.SetValidationDataHash(cs) + } return &sg, nil }