[#28] Client: Apply code optimizations
Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
766f61a5f7
commit
749000a090
57 changed files with 845 additions and 1116 deletions
|
@ -11,7 +11,7 @@ namespace FrostFS.SDK.Client;
|
|||
|
||||
internal static class ObjectTools
|
||||
{
|
||||
internal static FrostFsObjectId CalculateObjectId(FrostFsObjectHeader header, CallContext ctx)
|
||||
internal static FrostFsObjectId CalculateObjectId(FrostFsObjectHeader header, ClientContext ctx)
|
||||
{
|
||||
var grpcHeader = CreateHeader(header, [], ctx);
|
||||
|
||||
|
@ -21,9 +21,9 @@ internal static class ObjectTools
|
|||
return new ObjectID { Value = grpcHeader.Sha256() }.ToModel();
|
||||
}
|
||||
|
||||
internal static Object.Object CreateObject(FrostFsObject @object, CallContext ctx)
|
||||
internal static Object.Object CreateObject(FrostFsObject @object, ClientContext ctx)
|
||||
{
|
||||
@object.Header.OwnerId ??= ctx.OwnerId;
|
||||
@object.Header.OwnerId ??= ctx.Owner;
|
||||
@object.Header.Version ??= ctx.Version;
|
||||
|
||||
var grpcHeader = @object.Header.GetHeader();
|
||||
|
@ -46,14 +46,14 @@ internal static class ObjectTools
|
|||
|
||||
obj.Signature = new Signature
|
||||
{
|
||||
Key = ctx.GetPublicKeyCache(),
|
||||
Sign = ByteString.CopyFrom(ctx.Key!.SignData(obj.ObjectId.ToByteArray())),
|
||||
Key = ctx.Key.PublicKeyProto,
|
||||
Sign = ctx.Key.ECDsaKey.SignData(obj.ObjectId.ToByteArray()),
|
||||
};
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
internal static void SetSplitValues(Header grpcHeader, FrostFsSplit split, CallContext ctx)
|
||||
internal static void SetSplitValues(Header grpcHeader, FrostFsSplit split, ClientContext ctx)
|
||||
{
|
||||
if (split == null)
|
||||
return;
|
||||
|
@ -77,17 +77,17 @@ internal static class ObjectTools
|
|||
grpcHeader.Split.ParentHeader = grpcParentHeader;
|
||||
grpcHeader.Split.ParentSignature = new Signature
|
||||
{
|
||||
Key = ctx.GetPublicKeyCache(),
|
||||
Sign = ByteString.CopyFrom(ctx.Key.SignData(grpcHeader.Split.Parent.ToByteArray())),
|
||||
Key = ctx.Key.PublicKeyProto,
|
||||
Sign = ctx.Key.ECDsaKey.SignData(grpcHeader.Split.Parent.ToByteArray()),
|
||||
};
|
||||
}
|
||||
|
||||
grpcHeader.Split.Previous = split.Previous?.ToMessage();
|
||||
}
|
||||
|
||||
internal static Header CreateHeader(FrostFsObjectHeader header, byte[]? payload, CallContext ctx)
|
||||
internal static Header CreateHeader(FrostFsObjectHeader header, byte[]? payload, ClientContext ctx)
|
||||
{
|
||||
header.OwnerId ??= ctx.OwnerId;
|
||||
header.OwnerId ??= ctx.Owner;
|
||||
header.Version ??= ctx.Version;
|
||||
|
||||
var grpcHeader = header.GetHeader();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue