cs-codex-dist-tests/ProjectPlugins/CodexPlugin/CodexTypes.cs

123 lines
3.5 KiB
C#
Raw Normal View History

2024-03-26 09:03:52 +00:00
using Newtonsoft.Json;
2024-03-26 13:07:06 +00:00
using Utils;
2024-03-26 09:03:52 +00:00
namespace CodexPlugin
2024-03-25 14:46:45 +00:00
{
public class DebugInfo
{
public string[] Addrs { get; set; } = Array.Empty<string>();
2024-03-26 07:58:16 +00:00
public string Spr { get; set; } = string.Empty;
public string Id { get; set; } = string.Empty;
public string[] AnnounceAddresses { get; set; } = Array.Empty<string>();
2024-03-26 09:03:52 +00:00
public DebugInfoVersion Version { get; set; } = new();
public DebugInfoTable Table { get; set; } = new();
}
public class DebugInfoVersion
{
public string Version { get; set; } = string.Empty;
public string Revision { get; set; } = string.Empty;
public bool IsValid()
{
return !string.IsNullOrEmpty(Version) && !string.IsNullOrEmpty(Revision);
}
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
public class DebugInfoTable
{
public DebugInfoTableNode LocalNode { get; set; } = new();
public DebugInfoTableNode[] Nodes { get; set; } = Array.Empty<DebugInfoTableNode>();
}
public class DebugInfoTableNode
{
public string NodeId { get; set; } = string.Empty;
public string PeerId { get; set; } = string.Empty;
public string Record { get; set; } = string.Empty;
public string Address { get; set; } = string.Empty;
public bool Seen { get; set; }
2024-03-25 14:46:45 +00:00
}
public class DebugPeer
{
2024-03-26 07:58:16 +00:00
public bool IsPeerFound { get; set; }
2024-03-26 09:31:49 +00:00
public string PeerId { get; set; } = string.Empty;
public string[] Addresses { get; set; } = Array.Empty<string>();
2024-03-25 14:46:45 +00:00
}
2024-03-26 13:07:06 +00:00
public class LocalDatasetList
{
public LocalDataset[] Content { get; set; } = Array.Empty<LocalDataset>();
}
2024-03-25 14:46:45 +00:00
public class LocalDataset
{
2024-03-26 13:07:06 +00:00
public ContentId Cid { get; set; } = new();
public Manifest Manifest { get; set; } = new();
}
public class Manifest
{
public string RootHash { get; set; } = string.Empty;
public ByteSize OriginalBytes { get; set; } = ByteSize.Zero;
public ByteSize BlockSize { get; set; } = ByteSize.Zero;
public bool Protected { get; set; }
2024-03-25 14:46:45 +00:00
}
2024-03-26 10:39:59 +00:00
public class SalesRequestStorageRequest
{
public string Duration { get; set; } = string.Empty;
public string ProofProbability { get; set; } = string.Empty;
public string Reward { get; set; } = string.Empty;
public string Collateral { get; set; } = string.Empty;
public string? Expiry { get; set; }
public uint? Nodes { get; set; }
public uint? Tolerance { get; set; }
}
2024-03-25 14:46:45 +00:00
public class ContentId
{
public ContentId()
{
Id = string.Empty;
}
public ContentId(string id)
{
Id = id;
}
public string Id { get; }
public override bool Equals(object? obj)
{
return obj is ContentId id && Id == id.Id;
}
public override int GetHashCode()
{
return HashCode.Combine(Id);
}
}
public class CodexSpace
{
public int TotalBlocks { get; set; }
public int QuotaMaxBytes { get; set; }
public int QuotaUsedBytes { get; set; }
public int QuotaReservedBytes { get; set; }
2024-06-05 07:34:43 +00:00
public int FreeBytes => QuotaMaxBytes - (QuotaUsedBytes + QuotaReservedBytes);
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
2024-03-25 14:46:45 +00:00
}