[#11] Add Network Snapshot
Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
b69d22966f
commit
c988ff3c76
84 changed files with 2238 additions and 933 deletions
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using FrostFS.SDK.ModelsV2.Enums;
|
||||
|
||||
|
@ -5,8 +6,11 @@ namespace FrostFS.SDK.ModelsV2;
|
|||
|
||||
public class Object
|
||||
{
|
||||
public Object()
|
||||
public Object(ObjectId objectId, ObjectHeader header, byte[] payload)
|
||||
{
|
||||
ObjectId = objectId;
|
||||
Payload = payload;
|
||||
Header = header;
|
||||
}
|
||||
|
||||
public Object(ContainerId container, byte[] payload, ObjectType objectType = ObjectType.Regular)
|
||||
|
@ -14,43 +18,47 @@ public class Object
|
|||
Payload = payload;
|
||||
Header = new ObjectHeader(containerId: container, type: objectType, attributes: []);
|
||||
}
|
||||
|
||||
|
||||
public ObjectHeader Header { get; set; }
|
||||
public ObjectId ObjectId { get; set; }
|
||||
|
||||
public ObjectId? ObjectId
|
||||
{
|
||||
get; internal set;
|
||||
}
|
||||
|
||||
public byte[] Payload { get; set; }
|
||||
public Signature Signature { get; set; }
|
||||
|
||||
public Signature? Signature { get; set; }
|
||||
|
||||
public void SetParent(LargeObject largeObject)
|
||||
{
|
||||
Header.Split.ParentHeader = largeObject.Header;
|
||||
}
|
||||
if (Header?.Split == null)
|
||||
throw new Exception("The object is not initialized properly");
|
||||
|
||||
public ObjectId? GetParentId()
|
||||
{
|
||||
return Header.Split?.Parent;
|
||||
Header.Split.ParentHeader = largeObject.Header;
|
||||
}
|
||||
}
|
||||
|
||||
public class LargeObject(ContainerId container) : Object(container, [])
|
||||
{
|
||||
private SHA256 payloadHash = SHA256.Create();
|
||||
private readonly SHA256 payloadHash = SHA256.Create();
|
||||
|
||||
public void AppendBlock(byte[] bytes, int count)
|
||||
{
|
||||
Header.PayloadLength += (ulong)count;
|
||||
Header!.PayloadLength += (ulong)count;
|
||||
this.payloadHash.TransformBlock(bytes, 0, count, bytes, 0);
|
||||
}
|
||||
|
||||
public LargeObject CalculateHash()
|
||||
{
|
||||
this.payloadHash.TransformFinalBlock([], 0, 0);
|
||||
Header.PayloadCheckSum = this.payloadHash.Hash;
|
||||
Header!.PayloadCheckSum = this.payloadHash.Hash;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ulong PayloadLength
|
||||
{
|
||||
get { return Header.PayloadLength; }
|
||||
get { return Header!.PayloadLength; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +66,7 @@ public class LinkObject : Object
|
|||
{
|
||||
public LinkObject(ContainerId containerId, SplitId splitId, LargeObject largeObject) : base (containerId, [])
|
||||
{
|
||||
Header.Split = new Split(splitId)
|
||||
Header!.Split = new Split(splitId)
|
||||
{
|
||||
ParentHeader = largeObject.Header
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue