forked from TrueCloudLab/frostfs-sdk-go
[#223] object: Introduce new fields for ECHeader
* Introduce `parentSplitID`, `parentSplitParentID` fields for `ECHeader`; * Fix ECHeader's constructor; * Fix `Split` and `Reconstruct`; * Add unit-tests. Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
09b79d13f3
commit
3de256d05e
4 changed files with 152 additions and 13 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"crypto/ecdsa"
|
||||
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
)
|
||||
|
||||
// Split splits fully formed object into multiple chunks.
|
||||
|
@ -32,7 +33,15 @@ func (c *Constructor) Split(obj *objectSDK.Object, key *ecdsa.PrivateKey) ([]*ob
|
|||
chunk.SetPayload(payloadShards[i])
|
||||
chunk.SetPayloadSize(uint64(len(payloadShards[i])))
|
||||
|
||||
ec := objectSDK.NewECHeader(parent, uint32(i), uint32(len(payloadShards)), headerShards[i], uint32(len(header)))
|
||||
var parentSplitParentID *oid.ID
|
||||
if obj.HasParent() {
|
||||
splitParentID, ok := obj.Parent().ID()
|
||||
if ok {
|
||||
parentSplitParentID = &splitParentID
|
||||
}
|
||||
}
|
||||
|
||||
ec := objectSDK.NewECHeader(parent, obj.SplitID(), parentSplitParentID, uint32(i), uint32(len(payloadShards)), headerShards[i], uint32(len(header)))
|
||||
chunk.SetECHeader(ec)
|
||||
if err := setIDWithSignature(chunk, key); err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue